Customizing Admin Panel in Django

Image source: here

Probably, Django developers are the happiest ones, because Django itself provides an admin panel and saves developers from the waste of time. But in some cases, we at least want to change the theme or even the entire design of the admin panel, add a Google Analytics dashboard, and so on.

Instead of coding and wasting time to change the design, we can easily add themes and new features to our admin panel only by installing some ready packages and integrating them into our projects by doing some simple configurations

In this case, we’ll look through the django-jet-reboot package

Let’s begin:

  1. Install package:
pip install django-jet-reboot

2. Add it to installed apps before django.contrib.admin:

INSTALLED_APPS = (
...
'jet',
'django.contrib.admin',
)

3. Check Templates settings, context_processrors.request should be enabled:

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
...
'django.template.context_processors.request',
...
],
},
},
]

4. Add URL pattern to django_project.urls.py in this way:

urlpatterns = patterns(
url(r'^jet/', include('jet.urls', 'jet')), # Django JET URLS
url(r'^admin/', include(admin.site.urls)),

)
# You can use path, url or r'. It does not matter.

5. Database configurations:

py manage.py migrate jet

Collect static files if you are in a production environment

py managepy collectstatic

Now empty the cache of the browser and go to /admin. The nice look login page will welcome you:

Login page
General view of Admin Panel
Page to add users to the database

You can create a dashboard like below with django-jet:

Editable dashboard

To do that add ‘jet.dashboard’ to the Installed Apps before ‘jet’:

INSTALLED_APPS = (
'jet.dashboard'
'jet',
'django.contrib.admin',
)

And edit urls.py like that:

urlpatterns = patterns(
url(r'^jet/', include('jet.urls', 'jet')), # Jet urls
url(r'^jet/dashboard/', include('jet.dashboard.urls', 'jet- dashboard')),
url(r'^admin/', include(admin.site.urls)),

)

Migrate again:

python manage.py migrate dashboard

We finished all configurations and successfully integrated django-jet-reboot into our project. You can use other packages if you did not like this one. For example, django-admin-black. There is another tutorial on how to integrate it. Check it, if you want and make your choice

Thanks for reading. Stay tuned for more ✌

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store