View all Object in Django Template
Question:
In this django function
def request(request):
args = {"name": "name", 'message': "message"}
return render(request, 'request.html', args)
the template will get {{name}} and {{message}} variable…
But apart from these two variable one can also access {{user}} and {{LANGUAGES}} object on template which are set in RequestContext by middleware.
Is there a way to displayed/render every object/variable that are sent to template either by my custom response or by any middleware like IP Address of requesting client, and other information.
Answers:
You can use the debug
tag:
{% debug %}
You can get all variables and obj using debug
{% debug %}
If you want to print this vars for debugging only, try django debug toolbar
In this django function
def request(request):
args = {"name": "name", 'message': "message"}
return render(request, 'request.html', args)
the template will get {{name}} and {{message}} variable…
But apart from these two variable one can also access {{user}} and {{LANGUAGES}} object on template which are set in RequestContext by middleware.
Is there a way to displayed/render every object/variable that are sent to template either by my custom response or by any middleware like IP Address of requesting client, and other information.
You can use the debug
tag:
{% debug %}
You can get all variables and obj using debug
{% debug %}
If you want to print this vars for debugging only, try django debug toolbar