I love Django Debug Toolbar and I mainly use it just to see the variables passed to the template (shown under the "Templates" tab on the right menu).
But the variables are shown like this
{'form': <django.forms.models.OrderForm object at 0x1033937d0>}
{'csrf_token': <django.utils.functional.__proxy__ object at 0x103394cd0>}
{'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x103393510>,
'user': <django.utils.functional.SimpleLazyObject object at 0x10339b690>}
{'debug': True, 'sql_queries': '<<sql_queries>>'}
{'LANGUAGES': '<<languages>>',
'LANGUAGE_BIDI': False,
'LANGUAGE_CODE': 'en-us'}
{'MEDIA_URL': ''}
{'STATIC_URL': '/static/'}
{'TIME_ZONE': 'EDT'}
{'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x10339bb90>}
{'request': '<<request>>'}
For variables like form
, messages
, and request
, this list isn't very informative. Is there a way to dig deeper and view all the possible attributes for these kinds of variables? Kind of like playing with the API using python manage.py shell
for templates?
You can't do this with
django-debug-toolbar
but if you installdjango-extensions
you can use therunserver_plus
command. This replaces the default exception/debug screen with werkzug debugger which gives you access to an interactive shell.Check out a tutorial here
You can do this more efficiently using Django-Debug-Template: https://github.com/t0ster/django-debug-template
Just load template debugger by {% load debug %} first.
Then drop a shell from templates for a particular variable by {{ var|ipdb }}