jazzband / django-debug-toolbar

A configurable set of panels that display various debug information about the current request/response.
https://django-debug-toolbar.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
7.96k stars 1.03k forks source link

Django debug toolbar does not show my template context #229

Closed Uznick closed 10 years ago

Uznick commented 12 years ago

On the "Templates" panel there are only system django context variables, or contact variables that come from middlewares.

It would be great, if there was an option to debug the context variables that I add via my views too.

Uznick commented 12 years ago

I use render_to_response('index.html', c, context_instance=RequestContext(request)), if I remove context_instance, then everything becomes ok.

Django 1.3.1, django-debug-toolbar from the trunk.

thinred commented 12 years ago

Hi! This is a bug, no doubt about it, but could you check if render in Django 1.3 works for you? Basically it is equivalent to the code above and, well, shorter. Cheers!

Uznick commented 12 years ago

If you mean this: https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render, then in 1.3.1 it does not work. Shall I try with 1.3?

thinred commented 12 years ago

Yes, I mean this function. Do not try with 1.3 - let me take a look. :)

egrim commented 12 years ago

Using 1.3's render will not list any variables added by the dictionary passed to it because the context saved by DDT's middleware in panels/template.py:_store_template_info is later modified by django's template/loader.py:render_to_string method (with context_instance.pop() in the finally block).

Perhaps the _store_template_info method should store a copy of the context instead?

linovia commented 12 years ago

This is somewhat amazing. CBV are working well with DDJ. I noticed the way the templates are rendered is totally different between the two.

alanjds commented 11 years ago

+1

I tested version 0.8.5 and it works good I tested version 0.9 and it does not work

But using DATABASES settings dict instead of DATABASE_ENGINE breakes 0.8.5, so I needed to disable SQL pannel to make it work with Django 1.4.3

aaugustin commented 10 years ago

I think this was fixed in 264e6813cb4f70c4a8610d69dfbcb11d37d66e71.