Create Superuser and Admin Dashboard
In this guide, you will learn how to create a superuser for the Django admin dashboard.
1. Create Superuser
Create a superuser for the admin dashboard.
Terminal
python manage.py createsuperuser
Username: admin
Email address:
Password:
Password (again):
Superuser created successfully.
2. Admin Dashboard
To access the admin dashboard, run the server and navigate to http://localhost:8000/admin/
.
Terminal
python manage.py runserver
Navigate to http://localhost:8000/admin/
in your browser and log in with the superuser credentials.
3. Register Model
Register the model in the admin.py
file.
admin.py
from django.contrib import admin
from .models import Post
admin.site.register(Post)
4. Customize Admin Dashboard
Customize the admin dashboard by creating a new class in the admin.py
file.
admin.py
from django.contrib import admin
from .models import Post
class PostAdmin(admin.ModelAdmin):
list_display = ('title', 'author', 'created_date')
admin.site.register(Post, PostAdmin)
5. Admin Dashboard Features
The admin dashboard provides the following features:
- Add, edit, and delete records.
- Filter records.
- Search records.
- Export records to CSV, XML, and other formats.