From 6736d3b0fd7a4c533b3a399694f92e9d0077294a Mon Sep 17 00:00:00 2001 From: James Socol Date: Fri, 9 Nov 2012 12:32:36 -0500 Subject: [PATCH] Clarify docs and add EXCLUDE_APPS default. Fix #22. --- README.rst | 20 ++++++++++++++++---- docs/index.rst | 20 ++++++++++++++++---- jingo/__init__.py | 8 +++++++- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 2055a0b..21dc190 100644 --- a/README.rst +++ b/README.rst @@ -65,12 +65,24 @@ from the loader:: JINGO_EXCLUDE_APPS = ('debug_toolbar',) -If a template is in the *app folder*, ``debug_toolbar``, the Jinja loader will -raise a ``TemplateDoesNotExist`` exception. -This causes Django to move onto the next loader in ``TEMPLATE_LOADERS`` -to find a template - in this case, +If a template path begins with ``debug_toolbar``, the Jinja loader will raise a +``TemplateDoesNotExist`` exception. This causes Django to move onto the next +loader in ``TEMPLATE_LOADERS`` to find a template - in this case, ``django.template.loaders.filesystem.Loader``. +.. note:: + Technically, we're looking at the template path, not the app. Often these are + the same, but in some cases, like 'registration' in the default setting--which + is an admin template--they are not. + +The default is in ``jingo.EXCLUDE_APPS``:: + + EXCLUDE_APPS = ( + 'admin', + 'admindocs', + 'registration' + ) + If you want to configure the Jinja environment, use ``JINJA_CONFIG`` in ``settings.py``. It can be a dict or a function that returns a dict. :: diff --git a/docs/index.rst b/docs/index.rst index 34821f2..9fcbf87 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -65,12 +65,24 @@ from the loader:: JINGO_EXCLUDE_APPS = ('debug_toolbar',) -If a template is in the *app folder*, ``debug_toolbar``, the Jinja loader will -raise a ``TemplateDoesNotExist`` exception. -This causes Django to move onto the next loader in ``TEMPLATE_LOADERS`` -to find a template - in this case, +If a template path begins with ``debug_toolbar``, the Jinja loader will raise a +``TemplateDoesNotExist`` exception. This causes Django to move onto the next +loader in ``TEMPLATE_LOADERS`` to find a template - in this case, ``django.template.loaders.filesystem.Loader``. +.. note:: + Technically, we're looking at the template path, not the app. Often these are + the same, but in some cases, like 'registration' in the default setting--which + is an admin template--they are not. + +The default is in ``jingo.EXCLUDE_APPS``:: + + EXCLUDE_APPS = ( + 'admin', + 'admindocs', + 'registration' + ) + If you want to configure the Jinja environment, use ``JINJA_CONFIG`` in ``settings.py``. It can be a dict or a function that returns a dict. :: diff --git a/jingo/__init__.py b/jingo/__init__.py index 6ead3f5..54c4725 100644 --- a/jingo/__init__.py +++ b/jingo/__init__.py @@ -16,6 +16,12 @@ import jinja2 VERSION = (0, 4) __version__ = '.'.join(map(str, VERSION)) +EXCLUDE_APPS = ( + 'admin', + 'admindocs', + 'registration', +) + log = logging.getLogger('jingo') _helpers_loaded = False @@ -204,7 +210,7 @@ class Loader(BaseLoader): def load_template(self, template_name, template_dirs=None): if hasattr(template_name, 'rsplit'): app = template_name.rsplit('/')[0] - if app in getattr(settings, 'JINGO_EXCLUDE_APPS', []): + if app in getattr(settings, 'JINGO_EXCLUDE_APPS', EXCLUDE_APPS): raise TemplateDoesNotExist(template_name) try: template = env.get_template(template_name)