Replace default admin interface of django with grappelli

Dec 14, 2023    |   

For using Grappelli 3.0.8, Django 4.0 needs to be installed and an Admin Site has to be activated.

1. Installation

$ pip install django-grappelli


Go to https://github.com/sehmaschine/django-grappelli if you need to download a package or clone/fork the repository.

2. Setup
Open settings.py and add grappelli to your INSTALLED_APPS (before django.contrib.admin):

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


3. Add URL-patterns.

The grappelli URLs are needed for related–lookups and autocompletes. Your admin interface is available with the URL you defined for admin.site:

from django.conf.urls import include

urlpatterns = [
    path('grappelli/', include('grappelli.urls')), # grappelli URLS
    path('admin/', admin.site.urls), # admin site
]


4. Add the request context processor

It is needed for the Dashboard and the Switch User feature.

TEMPLATES = [
    {
        ...
        'OPTIONS': {
            'context_processors': [
                ...
                'django.template.context_processors.request',
                ...
            ],
        },
    },
]


5. Collect the media files:

$ python manage.py collectstatic


6. Start the devserver and login to your admin site:

$ python manage.py runserver <IP-address>:8000