{"id":13813991,"url":"https://github.com/stephenmcd/django-overextends","last_synced_at":"2025-04-13T05:25:22.351Z","repository":{"id":3544677,"uuid":"4604903","full_name":"stephenmcd/django-overextends","owner":"stephenmcd","description":"Circular template inheritance for Django","archived":false,"fork":false,"pushed_at":"2020-03-25T19:51:02.000Z","size":38,"stargazers_count":108,"open_issues_count":7,"forks_count":26,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-24T09:32:18.876Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stephenmcd.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":"2012-06-09T04:32:54.000Z","updated_at":"2025-02-22T18:10:02.000Z","dependencies_parsed_at":"2022-08-28T16:04:16.255Z","dependency_job_id":null,"html_url":"https://github.com/stephenmcd/django-overextends","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenmcd%2Fdjango-overextends","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenmcd%2Fdjango-overextends/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenmcd%2Fdjango-overextends/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenmcd%2Fdjango-overextends/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephenmcd","download_url":"https://codeload.github.com/stephenmcd/django-overextends/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248667077,"owners_count":21142364,"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-08-04T04:01:39.275Z","updated_at":"2025-04-13T05:25:22.325Z","avatar_url":"https://github.com/stephenmcd.png","language":"Python","funding_links":[],"categories":["Other","其它","Python"],"sub_categories":[],"readme":".. image:: https://secure.travis-ci.org/stephenmcd/django-overextends.png?branch=master\n   :target: http://travis-ci.org/stephenmcd/django-overextends\n\nCreated by `Stephen McDonald \u003chttp://twitter.com/stephen_mcd\u003e`_\n\nIntroduction\n============\n\nA Django reusable app providing the ``overextends`` template tag, a\ndrop-in replacement for Django's ``extends`` tag, which allows you to\nuse circular template inheritance.\n\nThe primary use-case for ``overextends`` is to simultaneously override\nand extend templates from other reusable apps, in your own Django project.\n\nExample\n=======\n\nConsider the following settings module and templates, with the apps\n``app1`` and ``app2`` bundled in the project, for example's sake::\n\n    # settings.py\n    INSTALLED_APPS = (\n        \"app1\",\n        \"app2\",\n        \"overextends\",\n    )\n    TEMPLATE_LOADERS = (\n        \"django.template.loaders.filesystem.Loader\",\n        \"django.template.loaders.app_directories.Loader\",\n    )\n    PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))\n    TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, \"templates\"),)\n\n    \u003c!-- myproject/app1/templates/pages/page.html --\u003e\n    \u003ch1\u003eTitle\u003c/h1\u003e\n    {% block main %}\n    \u003cp\u003eA paragraph in app1\u003c/p\u003e\n    {% enblock %}\n    \u003cfooter\u003eCopyright 2012\u003c/footer\u003e\n\n    \u003c!-- myproject/app2/templates/pages/page.html --\u003e\n    {% overextends \"pages/page.html\" %}\n    {% block main %}\n    \u003cp\u003eA paragraph in app2, that wants to be on top of app1's main block\u003c/p\u003e\n    {{ block.super }}\n    {% enblock %}\n\n    \u003c!-- myproject/templates/pages/page.html --\u003e\n    {% overextends \"pages/page.html\" %}\n    {% block main %}\n    {{ block.super }}\n    \u003cp\u003eA paragraph in the project's template directory, under the other main blocks\u003c/p\u003e\n    {% enblock %}\n\nThe resulting HTML rendered when ``pages/page.html`` was loaded would be::\n\n    \u003ch1\u003eTitle\u003c/h1\u003e\n    \u003cp\u003eA paragraph in app2, that wants to be on top of app1's main block\u003c/p\u003e\n    \u003cp\u003eA paragraph in app1\u003c/p\u003e\n    \u003cp\u003eA paragraph in the project's template directory, under the other main blocks\u003c/p\u003e\n    \u003cfooter\u003eCopyright 2012\u003c/footer\u003e\n\nFor a detailed analysis of why you would use this approach, how it works,\nand alternative approaches, read my initial blog post:\n`Circular Template Inheritance for Django`_\n\nInstallation\n============\n\nThe easiest way to install django-overextends is directly from PyPi\nusing `pip`_ by running the following command::\n\n    $ pip install -U django-overextends\n\nOtherwise you can download django-overextends and install it directly\nfrom source::\n\n    $ python setup.py install\n\nProject Configuration\n=====================\n\nOnce installed you can configure your project to use\ndjango-overextends by adding the ``overextends`` app to the\n``INSTALLED_APPS`` in your project's ``settings`` module::\n\n    INSTALLED_APPS = (\n        # ... other apps here ...\n        'overextends',\n    )\n\nFor Django 1.9+ you must add overextends to the `builtins` key of your `TEMPLATES` setting::\n\n    TEMPLATES = [\n        {\n            'BACKEND': 'django.template.backends.django.DjangoTemplates',\n            'APP_DIRS': True,\n            'OPTIONS': {\n                'builtins': ['overextends.templatetags.overextends_tags'],\n            }\n        },\n    ]\n\n\nNote that while the ``overextends`` tag is provided by the package\n``overextends.templatetags.overextends_tags``, it is unnecessary to use\n``{% load overextends_tags %}`` in your templates. Like the ``extends``\ntag, ``overextends`` must be the first tag in your template, so it is\nautomatically added to Django's built-in template tags, removing the\nneed to load its tag library in each template.\n\n.. _`Circular Template Inheritance for Django`: http://blog.jupo.org/2012/05/17/circular-template-inheritance-for-django/\n.. _`pip`: http://www.pip-installer.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenmcd%2Fdjango-overextends","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenmcd%2Fdjango-overextends","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenmcd%2Fdjango-overextends/lists"}