Tomas Tintera
Tomas Tintera

Reputation: 839

Priority of my app's admin template versus the build in one

I have customized template myapp\templates\admin (base_site.html). It is used only when I remove the original file C:\Python34\Lib\site-packages\django\contrib\admin\templates\admin\base.html

How can I have my customzized template used without changing the original Django installation? What settings should I check?

The new file source:

{% extends "admin/base.html" %}
{% load i18n %}
{% block title %}myApp - admin{% endblock %}

{% block branding %}
<h1 id="site-name">myApp - admin</h1>
{% endblock %}

{% block nav-global %}           
        <nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
            <a class="navbar-brand" href="{% url 'home' %}">{% trans 'Website home' %}</a>
            <a href="{% url 'admin:index' %}">{% trans 'Admin home' %}</a>
        </nav>
{% endblock %}

Upvotes: 1

Views: 122

Answers (1)

Alasdair
Alasdair

Reputation: 309029

The app directories template loader searches for templates based on the order of the INSTALLED_APPS setting.

In your case, make sure that your myapp appears above django.contrib.admin.

INSTALLED_APPS = (
    'myapp',
    ...
    'django.contrib.admin',
    ...
)

See the docs on the app directories loader for more info.

Upvotes: 1

Related Questions