Changing the base and stylesheets

Almost every admin page is extended from a common base template named admin/base_site.html. This means that with a little knowledge of HTML and CSS, you can make all sorts of customizations to change the look and feel of the
admin interface.

Create a directory called admin in any templates directory. Then, copy the base_site.html file from the Django source directory and alter it according to your needs. If you don't know where the templates are located, just run the following commands within the Django shell:

>>> from os.path import join 
>>> from django.contrib import admin 
>>> print(join(admin.__path__[0], "templates", "admin")) 
/home/arun/env/sbenv/lib/python3.6/site-packages/django/contrib/admin/templates/admin 

The last line is the location of all your admin templates. You can override or extend any of these templates.

For an example of overriding the admin base template, you can change the font of the entire admin interface to Special Elite from Google Fonts, which is great for giving a mock-serious look.

You will need to copy base_site.html from the admin templates to admin/base_site.html in one of your template's directories. Then, add the following lines to the end:

{% block extrastyle %} 
    <link href='http://fonts.googleapis.com/css?family=Special+Elite' rel='stylesheet' type='text/css'> 
    <style type="text/css"> 
     body, td, th, input { 
       font-family: 'Special Elite', cursive; 
     } 
    </style> 
{% endblock %} 

This adds an extra stylesheet for overriding the font-related styles and will be applied to every admin page.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.111.85