DEV Community

Cover image for Simplify Your Django Admin with django-unfold
Eshat Jubayer
Eshat Jubayer

Posted on

Simplify Your Django Admin with django-unfold

Django's built-in admin is incredibly powerful and highly customizable. However, customizing it from scratch can be time-consuming and daunting. Fortunately, there's an amazing package to address this issue: django-unfold. Built on top of Tailwind CSS, it’s not only powerful but also polished and highly customizable.

In this post, I’ll walk you through what django-unfold is, how to integrate it into your project, and how it can make managing your Django admin more intuitive.


What is django-unfold?

Unfold is a theme for the Django admin interface that incorporates best practices for building full-fledged admin areas. It is designed to enhance and extend the default administration features provided by Django.


Why Use It?

  • Highly Customizable
  • Polished Look
  • Dark Mode: Supports both light and dark mode versions.
  • Responsive Design
  • And Many More

For more details, visit their official website.


Getting Started

Step 1: Install django-unfold

Install the package via pip:

pip install django-unfold
Enter fullscreen mode Exit fullscreen mode

Step 2: Configure INSTALLED_APPS

Add unfold to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = [
    "unfold",  # Add this before django.contrib.admin
    "django.contrib.admin",
]
Enter fullscreen mode Exit fullscreen mode

Step 3: Apply django-unfold to Your Admin Models

In your app's admin.py, use django-unfold like this:

from django.contrib import admin
from .models import Doctor
from unfold.admin import ModelAdmin as UnfoldModelAdmin


@admin.register(Doctor)
class DoctorAdmin(UnfoldModelAdmin):
    pass
Enter fullscreen mode Exit fullscreen mode

If you want to customize filters and other admin options, you can do so like this:

@admin.register(Doctor)
class DoctorAdmin(UnfoldModelAdmin):
    list_display = (
        "first_name",
        "last_name",
        "specialization",
        "years_of_experience",
        "available",
        "date_joined",
    )
    list_filter = ("specialization", "available", "gender")
    search_fields = ("first_name", "last_name", "email", "phone")
Enter fullscreen mode Exit fullscreen mode

Example: Before and After

Below is an example of how django-unfold transforms the default Django admin theme:

django-unfold admin

If you found this helpful, let me know by leaving a 👍 or a comment!, or if you think this post could help someone, feel free to share it! Thank you very much!

Sentry blog image

Identify what makes your TTFB high so you can fix it

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

Read more

Top comments (3)

Collapse
 
aniruddhaadak profile image
ANIRUDDHA ADAK

wow amazing .

Collapse
 
eshat002 profile image
Eshat Jubayer

Glad you liked it!

Collapse
 
aniruddhaadak profile image
ANIRUDDHA ADAK

Thank you 😻

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay