Recommended preparation: set up a Django project and read the Django tutorial overview before trying the code.
The Django admin gives authorized staff a built-in interface to manage registered models. After migrating your database, create a superuser, register the Student model and visit /admin/ on your local Django server.
Terminal — create admin tables, account and development server
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
Open http://127.0.0.1:8000/admin/, sign in using the account you created, and access registered models. The screenshots below show typical admin screens; their appearance may differ by Django version.
django.contrib.admin, auth, sessions and messages apps are installed (included in a new Django project).python manage.py migrate.path("admin/", admin.site.urls).Student.plus2net_demo/urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path("admin/", admin.site.urls),
path("students/", include("students.urls")),
]
students/models.py
from django.db import models
class Student(models.Model):
name = models.CharField(max_length=100)
cl = models.CharField(max_length=20, db_column="class")
mark = models.PositiveSmallIntegerField()
gender = models.CharField(max_length=20)
def __str__(self):
return self.name
students/admin.py — simplest registration
from django.contrib import admin
from .models import Student
admin.site.register(Student)
After registration, the admin site provides add, change and delete interfaces according to user permissions.
students/admin.py — replace the simpler register() example, do not use both
from django.contrib import admin
from .models import Student
@admin.register(Student)
class StudentAdmin(admin.ModelAdmin):
list_display = ("id", "name", "cl", "mark", "gender")
list_filter = ("cl", "gender")
search_fields = ("name",)
ordering = ("id",)
list_display determines columns; list_filter adds filters; search_fields adds search. Choose one registration approach to avoid AlreadyRegistered.
For routine administration, prefer staff accounts with precisely scoped permissions rather than sharing a superuser credential. You can create users in the admin or with Django authentication tools. is_staff controls admin access, while specific model permissions determine allowed actions.


DEBUG=False in production, configure trusted hosts and HTTPS, and restrict who can access admin functions. The admin site is not a substitute for application-specific permission checks.admin.py and confirm the app is installed.Continue with MySQL setup for the Student model or forms to create a separate user-facing input experience.
An alternative: pagination and search on the changelist
@admin.register(Student)
class StudentAdmin(admin.ModelAdmin):
list_display = ("name", "cl", "mark")
list_per_page = 25
search_fields = ("name",)
An alternative: control the model edit-form layout
@admin.register(Student)
class StudentAdmin(admin.ModelAdmin):
fields = ("name", "cl", "mark", "gender")
readonly_fields = ()
Change the password for a named Django user
python manage.py changepassword admin_username
Use the admin configuration variants as alternatives. Never place multiple @admin.register(Student) classes in the same app unless you first unregister a previous registration.
The default Django project enables the admin app. It can be removed or customized for other architectures.
A superuser receives every model permission. Staff status allows access to the admin login, but individual permissions still control what normal staff users may do.
No. Register a model once. To change its admin behavior, use a single ModelAdmin class or replace the earlier registration.
Previous: List and detail pages
Browse the complete Django tutorial series.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.