Displaying template location in html

Skip to first unread message

Alec Taylor

Jan 29, 2012, 1:26:39 AM1/29/12
to django...@googlegroups.com
With 40+ HTML files it's easy to get confused as to where each
component comes from.

I don't want to annotate each file with its relative path manually, as
this will prove cumbersome when the site finally goes production.

Is there a trick to displaying the template location on-screen?

Thanks for all suggestions,

Alec Taylor

Mario Gudelj

Jan 29, 2012, 6:12:01 PM1/29/12
to django...@googlegroups.com
The only way to achieve this would be to pass the template path, inside the view, to the template and render it within the template.


    d = {'profile':profile:'template_path':"console/account-profile.html"}
    return render_to_response('console/account-profile.html', d)


Alec Taylor

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Jan 29, 2012, 8:19:44 PM1/29/12
to Django users
Use the Django Debug Toolbar, it shows all kinds of things. For
templates, it shows the names of all the templates that make up the
given page as well as which tags are used on the page.

With DDT, you don't have to annotate (and un-annotate) anything.


Alec Taylor

Jan 31, 2012, 7:31:49 AM1/31/12
to django...@googlegroups.com
Thanks donarb, I'll give that toolbar a try.

Mario: I though Python has all that fancy metaprogramming stuff like
Ruby with Objective C style reflection?

Ustun Ozgur

Jan 31, 2012, 8:51:05 AM1/31/12
to django...@googlegroups.com
+1 for debug toolbar. 

If you choose to do it manually though, you can make use of a middleware instead of passing templates in each view function explicitly, as shown here: http://djangosnippets.org/snippets/766/

Reply all
Reply to author
0 new messages