Unable to get consistent admin header and title

Hi all,

I have tried to make one or two custom views but am not able to get the site header and title as specified in urls.py to display just the default Django title. Here are my attempts so far that i have placed in the directories that correspond with the model I am using them in conjunction with:

{% extends "admin/change_list.html" %}
{% load static %}
{% block content %}

<h2><a href="upload-csv/">Upload a CSV file</a></h2>

{{ block.super }}
{% endblock %}
{% extends 'admin/base_site.html' %}

{% block content %}

...Content is here

{{ block.super }}

{% endblock %}

I am able to view both but am just getting the default Django banner and no side bar either. Hoping it may be a quick fix! :slight_smile:

djangobanner

Is this what you mean? sidewinder/appname/core/admin.py at master · stribny/sidewinder · GitHub

Or are you creating new pages in the admin and want to have different header that the Django admin?

Yes, that’s exatly it, I have those statements in my Admin.py and the custom title appears across the Admin interface. Just doesn’t appear in the templates using the code above. Do I need to duplicate the full templates for base_site.html and change_list.html in the templates folder?

EDIT: I actually have the below statements in urls.py. Is that incorrect?

admin.site.site_header = ‘Exam Records Management System’
admin.site.index_title = ‘Exam Admin Portal’

In that case I am not sure, I haven’t extended the admin with custom pages yet.

1 Like

See the docs at AdminSite Objects.

I think what you need to do here is subclass the standard AdminSite class and set those attributes in that class. Also see Overriding the default AdminSite.

1 Like

Thanks, Ken. Much appreciated!