0Pricing
Python Academy · Lesson

The Django Admin

Manage data with the admin site.

The Django Admin is a free Python Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Python Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The Built-in Admin

Django ships with a powerful admin site: an auto-generated web interface for managing your data. It is one of Django's most loved features.

# The admin gives you CRUD screens
# for your models with zero UI code
print('Django admin manages data out of the box')

Admin Is Already Installed

The admin lives in django.contrib.admin, included in INSTALLED_APPS by default, and is wired into the project urls.py.

# mysite/urls.py
from django.contrib import admin
from django.urls import path

urlpatterns = [
    path('admin/', admin.site.urls),
]
print('admin/ is mapped to the admin site')

Creating a Superuser

To log in you need an admin account. Create one with python manage.py createsuperuser and follow the prompts.

# python manage.py createsuperuser
# Username: admin
# Email: admin@example.com
# Password: ********
print('createsuperuser makes an admin login')

Logging In

Run the server and visit /admin/. Log in with your superuser credentials to reach the dashboard.

# python manage.py runserver
# Open http://127.0.0.1:8000/admin/
print('Visit /admin/ and log in')

Registering a Model

Models do not appear in the admin until you register them. Do this in the app's admin.py with admin.site.register().

# blog/admin.py
from django.contrib import admin
from .models import Post

admin.site.register(Post)
print('Post now appears in the admin')

Managing Data

Once registered, you get full CRUD screens: list all rows, add new ones, edit, and delete, all without writing any forms.

# In the admin you can:
# - view a list of all Posts
# - add a new Post
# - edit or delete existing ones
print('Full CRUD with no extra code')

Customizing with ModelAdmin

A ModelAdmin class customizes how a model appears. list_display chooses which columns show in the list view.

from django.contrib import admin
from .models import Post

class PostAdmin(admin.ModelAdmin):
    list_display = ('title', 'created', 'published')

admin.site.register(Post, PostAdmin)
print('list_display picks the columns')

Search and Filters

Add search_fields for a search box and list_filter for sidebar filters to navigate large datasets.

from django.contrib import admin
from .models import Post

class PostAdmin(admin.ModelAdmin):
    search_fields = ('title',)
    list_filter = ('published',)

admin.site.register(Post, PostAdmin)
print('Search box and sidebar filters added')

The register Decorator

The @admin.register() decorator is a clean alternative to calling admin.site.register() separately.

from django.contrib import admin
from .models import Post

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ('title',)
print('@admin.register is the decorator form')

__str__ Matters

Define __str__ on your model so the admin shows a readable label instead of 'Post object (1)'.

from django.db import models

class Post(models.Model):
    title = models.CharField(max_length=200)
    def __str__(self):
        return self.title
print('__str__ gives a readable admin label')

Permissions

The admin respects user permissions. You can create staff users with limited rights so not everyone has full superuser access.

# Staff users (is_staff=True) can access the admin
# Permissions control which models they can edit
print('Permissions limit admin access')

Quick Check

Test your admin knowledge.

Recap

You used the Django admin to manage data.

  • The admin is built in and mapped to /admin/
  • Create an account with createsuperuser
  • Register models in admin.py to get CRUD screens
  • ModelAdmin customizes columns, search, and filters
  • Define __str__ for readable labels; permissions limit access

Frequently asked questions

Is the “The Django Admin” lesson free?

Yes — the full text of “The Django Admin” is free to read here on the web, and the Python Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Python Academy course, upgrade to CoddyKit PRO.

What will I learn in “The Django Admin”?

Manage data with the admin site. You practise Python Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Python Academy?

No prior experience is required. Python Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “The Django Admin” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Python Academy lesson?

Yes. Every Python Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Projects and Apps
  2. Models and Migrations
  3. Views and URLs
  4. The Django Admin
← Back to Python Academy