Skip to content

Commit

Permalink
Remove add_to_builtins() call from init, need explicit setup in Djang…
Browse files Browse the repository at this point in the history
…o 1.9
  • Loading branch information
vdboor committed Oct 22, 2015
1 parent 7a5da8b commit 3ad0f56
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
23 changes: 23 additions & 0 deletions README.rst
Expand Up @@ -30,6 +30,29 @@ Add the module to the installed apps::
'debugtools',
)

As of Django 1.9, either use ``{% load debugtools_tags %}`` or add the following to the settings:

.. code-block:: python
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
# ...
],
'builtins': [ # Add this section
"debugtools.templatetags.debugtools_tags", # Add this line
],
},
},
]
Features
--------

Expand Down
20 changes: 11 additions & 9 deletions debugtools/__init__.py
Expand Up @@ -3,12 +3,14 @@

VERSION = (1, 4)

# Make sure the ``{% print %}`` is always available, even without a {% load debug_tags %} call.
# **NOTE** this uses the undocumented, unofficial add_to_builtins() call. It's not promoted
# by Django developers because it's better to be explicit with a {% load .. %} in the templates.
#
# This function is used here nevertheless because the {% print %} tag is a debugging aid,
# and not a tag that should remain permanently in your templates. Convenience is preferred here.
#
from django.template.base import add_to_builtins
add_to_builtins("debugtools.templatetags.debug_tags")
import django
if django.VERSION < (1,9):
# Make sure the ``{% print %}`` is always available, even without a {% load debugtools_tags %} call.
# This feature is no longer available in Django 1.9, which adds an explicit configuration for it:
# see: https://docs.djangoproject.com/en/1.9/releases/1.9/#django-template-base-add-to-builtins-is-removed
#
# This function is used here because the {% print %} tag is a debugging aid,
# and not a tag that should remain permanently in your templates. Convenience is preferred here.
#
from django.template.base import add_to_builtins
add_to_builtins("debugtools.templatetags.debug_tags")

0 comments on commit 3ad0f56

Please sign in to comment.