Django customize the admin page template

 Description

By default, admin page shows text django administration. We can change the existing layout.

 Qqq AA .

  • aaqa templates directory in your project directory (the one that contains manage.py).


  • 'DIRS': [BASE_DIR / 'templates'],


  • Now create a directory called admin inside templates, and copy the template admin/base_site.html 
[dj_adm@localhost mysite]$ source ~/virtualenvs/dj-env/bin/activate
(dj-env) [dj_adm@localhost mysite]$ python -c "import django; print(django.__path__)"
['/home/dj_adm/virtualenvs/dj-env/lib/python3.9/site-packages/django']
(dj-env) [dj_adm@localhost mysite]$ cd /home/dj_adm/virtualenvs/dj-env/lib/python3.9/site-packages/django
(dj-env) [dj_adm@localhost django]$ ls -ltr

 

(dj-env) [dj_adm@localhost admin]$ pwd
/home/dj_adm/virtualenvs/dj-env/lib/python3.9/site-packages/django/contrib/admin/templates/admin
(dj-env) [dj_adm@localhost admin]$ mkdir -p ~/dj-practice/mysite/templates/admin/
(dj-env) [dj_adm@localhost admin]$ cp base_site.html ~/dj-practice/mysite/templates/admin/
(dj-env) [dj_adm@localhost admin]$ 

 

{% 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 %}

 


 

 

 

 

Comments

Popular posts from this blog

Django Server setup with Apache with mod_wsgi in Centos 9

Mysql Installation on CentOS 9

Install mysql8 on centOS 9 and integrating with Django