{"id":19300649,"url":"https://github.com/fantomas42/django-app-namespace-template-loader","last_synced_at":"2025-04-22T10:31:57.531Z","repository":{"id":10728777,"uuid":"12982010","full_name":"Fantomas42/django-app-namespace-template-loader","owner":"Fantomas42","description":"Template loader allowing you to both extend and override a template at the same time.","archived":false,"fork":false,"pushed_at":"2020-03-06T14:57:02.000Z","size":93,"stargazers_count":59,"open_issues_count":2,"forks_count":18,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2024-10-08T11:29:07.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Alexpux/MINGW-packages","license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fantomas42.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-20T19:25:23.000Z","updated_at":"2023-03-30T06:38:15.000Z","dependencies_parsed_at":"2022-08-31T02:40:32.146Z","dependency_job_id":null,"html_url":"https://github.com/Fantomas42/django-app-namespace-template-loader","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fantomas42%2Fdjango-app-namespace-template-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fantomas42%2Fdjango-app-namespace-template-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fantomas42%2Fdjango-app-namespace-template-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fantomas42%2Fdjango-app-namespace-template-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fantomas42","download_url":"https://codeload.github.com/Fantomas42/django-app-namespace-template-loader/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223892994,"owners_count":17220834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T23:15:26.330Z","updated_at":"2024-11-09T23:15:26.961Z","avatar_url":"https://github.com/Fantomas42.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"====================================\nDjango App Namespace Template Loader\n====================================\n\n|travis-develop| |coverage-develop|\n\nProvides a template loader that allows you to load a template from a\nspecific application. This allows you to both **extend** and **override** a\ntemplate at the same time.\n\nThe default Django loaders require you to copy the entire template you want\nto override, even if you only want to override one small block.\n\nThis is the issue that this package tries to resolve.\n\nExamples:\n---------\n\nYou want to change the titles of the admin site, you would originally\ncreated this template: ::\n\n    $ cat my-project/templates/admin/base_site.html\n    {% extends \"admin/base.html\" %}\n    {% load i18n %}\n\n    {% block title %}{{ title }} | My Project{% endblock %}\n\n    {% block branding %}\n    \u003ch1 id=\"site-name\"\u003eMy Project\u003c/h1\u003e\n    {% endblock %}\n\n    {% block nav-global %}{% endblock %}\n\nExtend and override version with a namespace: ::\n\n    $ cat my-project/templates/admin/base_site.html\n    {% extends \"admin:admin/base_site.html\" %}\n\n    {% block title %}{{ title }} - My Project{% endblock %}\n\n    {% block branding %}\n    \u003ch1 id=\"site-name\"\u003eMy Project\u003c/h1\u003e\n    {% endblock %}\n\nNote that in this version the block ``nav-global`` does not have to be\npresent because of the inheritance.\n\nShorter version without namespace: ::\n\n    $ cat my-project/templates/admin/base_site.html\n    {% extends \":admin/base_site.html\" %}\n\n    {% block title %}{{ title }} - My Project{% endblock %}\n\n    {% block branding %}\n    \u003ch1 id=\"site-name\"\u003eMy Project\u003c/h1\u003e\n    {% endblock %}\n\nIf we do not specify the application namespace, the first matching template\nwill be used. This is useful when several applications provide the same\ntemplates but with different features.\n\nExample of multiple empty namespaces: ::\n\n    $ cat my-project/application/templates/application/template.html\n    {% block content %}\n    \u003cp\u003eApplication\u003c/p\u003e\n    {% endblock content %}\n\n    $ cat my-project/application_extension/templates/application/template.html\n    {% extends \":application/template.html\" %}\n    {% block content %}\n    {{ block.super }}\n    \u003cp\u003eApplication extension\u003c/p\u003e\n    {% endblock content %}\n\n    $ cat my-project/templates/application/template.html\n    {% extends \":application/template.html\" %}\n    {% block content %}\n    {{ block.super }}\n    \u003cp\u003eApplication project\u003c/p\u003e\n    {% endblock content %}\n\nWill render: ::\n\n    \u003cp\u003eApplication\u003c/p\u003e\n    \u003cp\u003eApplication extension\u003c/p\u003e\n    \u003cp\u003eApplication project\u003c/p\u003e\n\nInstallation\n------------\n\nFirst of all install ``django-app-namespace-template-loader`` with your\nfavorite package manager. Example : ::\n\n    $ pip install django-app-namespace-template-loader\n\nOnce installed, add ``app_namespace.Loader`` to the ``TEMPLATE_LOADERS``\nsetting of your project. ::\n\n    TEMPLATE_LOADERS = [\n      'app_namespace.Loader',\n      ... # Other template loaders\n    ]\n\nWith Django \u003e= 1.8 ``app_namespace.Loader`` should be added to the\n``'loaders'`` section in the OPTIONS dict of the ``DjangoTemplates`` backend\ninstead. ::\n\n    TEMPLATES = [\n        {\n            'BACKEND': 'django.template.backends.django.DjangoTemplates',\n            'OPTIONS': {\n                'loaders': [\n                    'app_namespace.Loader',\n                    'django.template.loaders.filesystem.Loader',\n                    'django.template.loaders.app_directories.Loader',\n                ],\n            },\n        },\n    ]\n\nNote: With Django 1.8, ``app_namespace.Loader`` should be first in the list\nof loaders.\n\nKnown limitations\n=================\n\n``app_namespace.Loader`` can not work properly if you use it in conjunction\nwith ``django.template.loaders.cached.Loader`` and inheritance based on\nempty namespaces.\n\nNotes\n-----\n\nBased originally on: http://djangosnippets.org/snippets/1376/\n\nRequires: Django \u003e= 1.8\n\nTested with Python 2.7, 3.3, 3.4.\n\nIf you want to use this application for previous versions of Django, use the\nversion 0.3.1 of the package.\n\nIf you want to use this application with Python 2.6, use the version 0.2 of\nthe package.\n\n.. |travis-develop| image:: https://travis-ci.org/Fantomas42/django-app-namespace-template-loader.png?branch=develop\n   :alt: Build Status - develop branch\n   :target: http://travis-ci.org/Fantomas42/django-app-namespace-template-loader\n.. |coverage-develop| image:: https://coveralls.io/repos/Fantomas42/django-app-namespace-template-loader/badge.png?branch=develop\n   :alt: Coverage of the code\n   :target: https://coveralls.io/r/Fantomas42/django-app-namespace-template-loader\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffantomas42%2Fdjango-app-namespace-template-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffantomas42%2Fdjango-app-namespace-template-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffantomas42%2Fdjango-app-namespace-template-loader/lists"}