A small collection of template tags for debugging and introspecting templates
Project description
A small collection of template tags for debugging and introspecting templates
Installation
Packaging on pypi isn’t complete yet. For now you’ll need to clone the repo into your virtualenv’s site-packages, or pip install the egg from github directly.
Setup
Go to your local settings.py (be sure the settings file is not used for a production environment) and add ‘template_debug’ to your installed apps via:
INSTALLED_APPS.append('template_debug')
N.B. - You will need to change your INSTALLED_APPS setting to a list in your base settings.py if it is a tuple.
Add the following to your local_settings.py:
TEMPLATE_DEBUG = True
Without this setting, the debug templates will return without doing anything. This behavior prevents your application from calling set_trace() or print in a production environment if some stray tags are committed in your templates.
Examples
To use django-template-debug simply load the debug tags in a template as follows:
{% load debug_tags %}
Be sure to put your tags inside of a section that you are certain will be rendered. (e.g. make sure the tags are not inside of if tags or not inside of a block tag when needed)
The available tags are outlined below:
- {% set_trace %}
Starts a set_trace while the template is being rendered. The context is available inside of this tag as the variable ‘context’. ipdb is used if available; otherwise the tag falls back to pdb.
- {% attributes <variable_name> %}
Prints the attributes of the variable provided to the console using dir()
- {% details <variable_name> %}
Prints a dictionary in the pattern {attribute: value} of the variable provided, for any attribute’s value that can be obtained without raising an exception or making a method call.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for django-template-debug-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4984b8f388d7d0f49e525c5d6d5ffb3470b15ef57fb3aec01d864d1bb4559ca6 |
|
MD5 | 98f5c18199fe04a53ffb39d1e66b6706 |
|
BLAKE2b-256 | 61ec494a6c580951a72f9b3aaac57196df752d540dcc8a8e5cc0b60f0345001c |