CUSTOMIZING (COLORS) DJANGO ADMIN PANEL

sachinchaurasiya

Sachin Chaurasiya

Posted on October 5, 2020

CUSTOMIZING (COLORS) DJANGO ADMIN PANEL

In this blog we’ll see how to change the default Django admin panel colors. we have always seen Django admin with a standard greenish-blue color but we can customize Django admin theme and change its color because everything can be edited and customized which is one of the coolest parts of this great framework.

Let’s dive into how to do that, The main question here arises, why would someone wants to change the color scheme of the admin aside from the obvious reason that they like some other color better.

There are a couple of different ways of achieving that, but for now we will achieve this using third-party package.

Using A Package:

There is this package available which we can use django-admin-interface to change the color of admin.
Alt Text

This provides enough customization for a regular user.

When using this approach:

It is easy to Implement and change the color whenever we want dynamically without having to change the code.
It can change solid colors. Gradients or other custom changes are not available.
These changes of color are saved on the DB so on a fresh DB every time it comes with default colors.

Lets Do this



#install package
pip install django-admin-interface


Enter fullscreen mode Exit fullscreen mode

Add admin_interface, flat_responsive, flat and colorfield to settings. INSTALLED_APPS
before django.contrib.admin



 INSTALLED_APPS = [ 
#... 
'admin_interface', 
'flat_responsive', # only if django version < 2.0 
'flat', # only if django version < 1.9 
'colorfield', 
'django.contrib.admin', 
#... ] 
X_FRAME_OPTIONS='SAMEORIGIN' # only if django version >= 3.0


Enter fullscreen mode Exit fullscreen mode


python manage.py migrate
python manage.py collectstatic


Enter fullscreen mode Exit fullscreen mode

Restart your application server and now you should be able to see a new color scheme added by the package. If you want to customize it further go to your admin and look for “themes” app and do customizations there.

http://localhost:8000/admin/admin_interface/theme/

Alt Text

A couple of favorite customizations there apart from colors are:

Use dropdown for your list_filter
Add/Change Favicon and logo for admin
Rounded corners for a slight step towards “modern” design.

Comment down if you like it 👍.also Comment down if you have any queries.

Thank you.

💖 💪 🙅 🚩
sachinchaurasiya
Sachin Chaurasiya

Posted on October 5, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related