Django Admin Theme(AdminLTE) – Easy integration in 5 minutes

Django Admin Theme

Hello Techies,

In this blog, we will discuss the Django admin theme integration. Most developers have questions on how to change the Django admin theme? So I am creating this blog to solve this problem. I’ve covered several topics based on the Django admin interface, such as how to create superuser, how to register models in Django admin interface, Django Admin UI customization.

Let’s integrate AdminLTE themes into our Django admin interface. More for information their official site.

Django Admin Theme Integration

Let’s create a Django application.

  1. Open the command shell (or terminal window) and make sure you’re in your virtual environment.
  2. Navigate to where you want to store Django apps and create a folder for your new website.
django-admin startproject django_admin_theme

The above command will create a folder / file structure as follows.

django_admin_theme/
    django_admin_theme/
        __init__.py
        settings.py
        urls.py
        wsgi.py
        asgi.py
    manage.py
    db.sqlite3

Let’s run the Django Admin application using 127.0.0.1:8000/admin URL. It will looks like below image.

Admin Interface

let’s decorate this boring theme. For this Django Admin Interface, we are using the AdminLTE theme.

Follow the steps below to integrate the Django admin theme.

AdminLTE theme Installation

Install the theme using pip:

pip install django-adminlte3

Add to installed apps in settings.py file.

Note: Add these apps at the beginning of the list, not at the end of the list. Also, add the STATIC_ROOT path.

# settings.py

INSTALLED_APPS = [
# General use templates & template tags (should appear first)
'adminlte3',
# Optional: Django admin theme (must be before django.contrib.admin)
'adminlte3_theme',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

]

STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = '/static/'

After adding the above code, run the following command to collect static.

python manage.py collectstatic 

The Django Admin Theme should then be changed as expected. Check some images of Admin Login and interface after integration.

Login Screen

Admin Interface

See the official site for more information about this package.

I hope you understand AdminLTE theme integration with the Django admin interface. Comment below if you still have any issues below.

Check the source code of Django admin theme on GitHub.

Leave a Comment