Skip to content
Django template loader that allows you to load and override a template from a specific Django application.
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
apptemplates
.gitignore
.travis.yml
LICENSE.txt
MANIFEST.in
README.rst
setup.py
tests.py
tox.ini

README.rst

Django apptemplates Latest version on PyPI

Build status Code Health Python versions Software license

django-apptemplates is a Django template loader that allows you to load a template from a specific application. By this you can both extend and override a template at the same time. The default Django loaders require you to copy the entire template you want to override, even if you only want to override one small block.

Based on: http://djangosnippets.org/snippets/1376/

Version Support

django-apptemplates is tested against the officially supported combinations of Python and Django, since Django 1.4 (Django 1.4 to 2.0 on Python 2.6 to 3.6).

Installation, Setup and Use

This package is available from PyPI. To install it simply execute:

$ pip install django-apptemplates

Settings (for Django 1.8+)

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'OPTIONS': {
            'loaders': [
                'apptemplates.Loader',
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
            ],
        },
    },
]

Settings (for Django < 1.8)

TEMPLATE_LOADERS = (
    'apptemplates.Loader',
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

How to Use in Templates

Template usage example (extend and override Django admin base template):

{% extends "admin:admin/base.html" %}

The part before the colon (:) is called the Django app namespace.

Alternatives

Authors and Maintainers

Change Log

1.4

  • Fix Origin missing loader and template_name attrs -- Thanks Brendan Roy, @bmon, and Matthew Somerville, @dracos!
  • Also test against Django 2.0

1.3

  • Add template loader to returned Origins -- Thanks J.J., @jdotjdot!
  • Also test against Python 3.6 -- Thanks Justin Walgran, @jwalgran!

1.2

  • Reestablish support for Django 1.4 through 1.8 (broken since version 1.1)
  • Add tests for template rendering
  • Drop support for Django 1.3 (which cannot be confirmed by tests)
  • Drop support for Python 2.4 and 2.5 (which cannot be tested anymore)

1.1.1

  • Fix ImportError for Django 1.8 (broken in release 1.1)
  • Add integration tests (test import of package across supported versions)
  • Add clean and test commands to setup.py

1.1

  • Use django.template.Origin in computation of template location for Django 1.9 compatibility. -- Thanks, Gilles Crettenand!

1.0

  • Remove Django 1.9 deprecation warning of imports
  • Update README with instructions for Django 1.8+

0.2

Skipped to fix conflicting versioning in setup.py and the PyPI package

0.0.1

  • Released as originally published on djangosnippets
You can’t perform that action at this time.