Skip to content

Visual introspection of Django's templates -- point and inspect where each tag came from (chain of its templates and views)

Notifications You must be signed in to change notification settings

235/django-template-introspection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Template Introspection

Did you ever had a web project which gave you hard times to find which bit of code generates the output? This project is developed with an idea to help a developer in finding exact view(function) and template wich were used to generat every HTML tag in a resulting output.

And yes, it allows you to find the roots of all your content on a page visually in a browser:

Screen sample

Installation

  • Download the source, add drop django_template_introspection somewhere in the python path
  • Add django_template_introspection to the INSTALLED_APPS and django_template_introspection.middleware.TemplateIntrospect to the MIDDLEWARE_CLASSES. For example, drop this to your settings.py somewhere to the very bottom (better to your settings-local.py):
DTI_DEBUG = True
if DTI_DEBUG:
    MIDDLEWARE_CLASSES += ('django_template_introspection.middleware.TemplateIntrospect',)
    INSTALLED_APPS += ('django_template_introspection',)

Done! Next, you can:

  • Investigate the HTML output in your browser
  • Find out where each HTML tag was generated (its template & view function)

Notes

  • Requires jQuery which is taken from a CDN, so it requires connection to Internet. Easy to fix

TODO

  • clean-up js code (replace pop-up plugin?)
  • preserve the order of templates inclusion in the resulting output (is it a js problem?)
  • override the template-tag generator to mark template-tags in the inspection output also. They are processed during a template rendering and therefore are not currently highlighted. However, they are distinct chunks of code and have to be shown separately.

Credits

  • using jGrowl for nice pop-ups
  • using js code borrowed from galambalazs for highliting and selecting HTML-elements
  • the idea of creating this module was offered by askalyuk

About

Visual introspection of Django's templates -- point and inspect where each tag came from (chain of its templates and views)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published