Django

Django Admin

Admin interface

Django Admin

Django provides a ready-to-use admin interface for managing your models. It's automatically generated based on your models.

Register Models

Register your models in admin.py:

from django.contrib import admin
from .models import Person

admin.site.register(Person)

Customize Admin

You can customize how models appear in the admin:

from django.contrib import admin
from .models import Person

@admin.register(Person)
class PersonAdmin(admin.ModelAdmin):
    list_display = ('first_name', 'last_name', 'age', 'email')
    list_filter = ('age',)
    search_fields = ('first_name', 'last_name', 'email')
    ordering = ('last_name', 'first_name')

Access Admin Interface

Start the development server and navigate to http://127.0.0.1:8000/admin/

Create Superuser

To access the admin, you need a superuser account:

python manage.py createsuperuser

Admin Features

  • Add, edit, and delete records
  • Search and filter records
  • Customize list display
  • Bulk actions
  • User management

Tip: The Django admin is a powerful tool for managing your application's data during development and production.