Hello, everyone, I’m new here and trying to re-learn Django.
I have followed the tutorial up to part 7 and in the section where it teaches me to override the admin area templates, but my changes to the HTML file are not showing up when I run the server.
Some screenshots of the issue are provided below.
In part 7 of the tutorial, the base_site.html override is not getting applied when I run the server.
After making this change, are you stopping and restarting runserver? Are you then refreshing the page in your browser?
Side note: In the future, please don’t post images of code. Copy/paste the code into the body of your message, surrounded by lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```.
Yes, I tried restarting the server, refreshing the page and disabling cache in the Network tab of DevTools.
Thanks for the heads up about the code formatting, I’ll keep it in mind.
Ok, I see where you missed the instructions in Writing your first Django app, part 7 | Django documentation | Django.
What’s in the docs:
Then, edit the file and replace {{ site_header|default:_(‘Django administration’) }} (including the curly braces) with your own site’s name as you see fit. You should end up with a section of code like:
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">Polls Administration</a></h1>
{% endblock %}
That’s not what you have for this block of template code in the code you’ve posted.
Thank you! I did not realize that site_header
was actually set somewhere.
This is what base_site.html looks like for me and it still doesn’t work:
{% extends "admin/base.html" %}
{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">Polls Administration</a></h1>
{% endblock %}
{% block nav-global %}{% endblock %}
This topic has been marked as solved.
I suggest you open a new topic to address your issue. Additionally, you may want to specify what directory this template is in, along with your TEMPLATES
setting.