Login

Tag "template-loader"

Snippet List

Load template from specific app

This is an updated of version snippets: * [https://djangosnippets.org/snippets/10489/](https://djangosnippets.org/snippets/10489/) * [https://djangosnippets.org/snippets/1376/](https://djangosnippets.org/snippets/10489/) Tested to with with Django 3.2 With this template loader you can extend templates from built-in Django apps such as Django admin. Example: {% extends "admin:admin/index.html" %} {% block sidebar %} {{block.super}} <div> < h1>Statistics< /h1> < a href="/admin/station/stats/">Published Stations< /a> </div> {% endblock %} Configuration: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ 'your_app/templates' ], 'OPTIONS': { # (...) # See: https://docs.djangoproject.com/en/3.2/ref/templates/api/#django.template.loaders.cached.Loader 'loaders': [ ('django.template.loaders.cached.Loader', [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', 'your_app.template_loaders.SpecificAppTemplateLoader', ]), ], }, }, ]

  • template-loader
Read More

1 snippet posted so far.