Skip to main content

Django template loader that allows you to load and override a template from a specific Django application.

Project description

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/

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

0.0.1

  • Released as originally published on djangosnippets

0.2

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

1.0

  • Remove Django 1.9 deprecation warning of imports

  • Update README with instructions for Django 1.8+

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

django-apptemplates-1.0.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file django-apptemplates-1.0.tar.gz.

File metadata

File hashes

Hashes for django-apptemplates-1.0.tar.gz
Algorithm Hash digest
SHA256 2c18c5a36365382fa27548762a5856b264e92b5b7b3cbe84fa045d35f8620d25
MD5 f547f736747e6b89d54200a0b3201644
BLAKE2b-256 8145f10009377e5f8d72f2954578d9ee2deee461fef8aa79a1f35dda3c4126d7

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page