01 Prepare the Note model
Complete the ORM tutorial first and apply its migration. Django's admin is already enabled in a default project. Registering a model gives staff an interface for managing its records.
02 Register the model
Put this in core/admin.py. list_display controls the table columns; search_fields adds a search box; list_filter adds a sidebar filter.
from django.contrib import admin
from .models import Note
@admin.register(Note)
class NoteAdmin(admin.ModelAdmin):
list_display = ("title", "created_at")
search_fields = ("title", "body")
list_filter = ("created_at",)
readonly_fields = ("created_at",)03 Create an administrator
Use an individual account and a strong password. The command asks for credentials interactively. Start the development server after creating the account.
python manage.py createsuperuser
python manage.py runserver04 Add and find a note
Visit http://127.0.0.1:8000/admin/, sign in, and choose Notes. Create two records, search for a word from one title, and try the date filter. The admin is an internal editing tool; use your own views for a public-facing reading experience.
Read the official Django documentation for details and more examples.