ikechi
ikechi

Reputation: 329

Can't change Django admin template

just started an official Django tutorial and already ran into a problem, can't change page name in admin panel. I'm trying to replace a default Django administration with something custom in the base_site.html as suggested in the tutorial (a file which I copied from the django source directory into my app, tried to move it in/out polls directory etc.),
I have added in settings TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')], and in installed apps also 'polls', but nothing changes.

Any suggestions what I can do in order to make it work?

Thanks

Upvotes: 3

Views: 2263

Answers (2)

iboss
iboss

Reputation: 486

It will not work if you only change the value inside the parentheses like this

{{ site_header|default:_('Your custom name') }}

What you need to do is you must replace all of the above with your desired name like this.

{% extends "admin/base.html" %}

{% block title %}{{ title }} | YOUR CUSTOM NAME{% endblock %}

{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">YOUR CUSTOM NAME</a></h1>
{% endblock %}

{% block nav-global %}{% endblock %}

Upvotes: 5

Mazv&#233;l
Mazv&#233;l

Reputation: 1009

I created a templates folder at the root level of my Django Site.

base-folder 
--apps
--templates 
----admin 
------base_site.html

I edited base_site.html like I wanted, I just changed the name like you are trying to. Then I added this line into my settings.py

TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]

This worked for me. If you are seeing the admin site when you type /admin that means your url-config is set. Just make sure that your TEMPLATE_DIRS matches the directory of the admin template. You should have admin directory within the templates directory that contains all the necessary templates for the admin page.

Upvotes: 1

Related Questions