Reputation: 6594
I have a reusable app with a directory structure like this:
myapp/
myapp/
views.py
models.py
...etc
templates/
myapp/
template1.html
...etc
admin/
index.html
test/
...testing stuff
setup.py
...etc
I'm overriding the index.html
admin template so that I can add some additional links in {% block userlinks %}
that will appear in a project's navigation when it uses my app.
However, when using my app inside a project, the admin homepage still uses Django's own index.html
file. The project itself has a base_site.html
that it uses, but the template inheritance diagram (in django-debug-toolbar
) looks like this:
/path/to/virtualenv/django/contrib/admin/templates/admin/index.html
/projectpath/projectname/templates/admin/base_site.html
/path/to/virtualenv/django/contrib/admin/templates/admin/base.html
...that first entry should be the index.html
file in my app's templates directory! Does anyone know why it's not being found? I can post settings if needed.
Upvotes: 0
Views: 128
Reputation: 31474
Django's template loader looks for templates in the order that apps are defined in INSTALLED_APPS
. In your case you must have defined django.contrib.admin
ahead of your app, so Django will always look there first and use the first template it finds.
Change it so that your app is first in the list:
INSTALLED_APPS = [
'myapp',
'django.contrib.admin',
...
]
Upvotes: 1