Django comes with a built-in admin interface—no coding required!
1. Create a Superuser
Run:
python manage.py createsuperuser
Follow the prompts.
2. Register Models for Admin
Edit tracker/admin.py
:
from django.contrib import admin
from .models import Category, Transaction
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
list_display = ['name']
@admin.register(Transaction)
class TransactionAdmin(admin.ModelAdmin):
list_display = ['date', 'transaction_type', 'category', 'amount']
list_filter = ['transaction_type', 'category', 'date']
search_fields = ['notes']
3. Run the Server & Use Admin
python manage.py runserver
Go to http://127.0.0.1:8000/admin/
Now you can add, edit, delete, and search transactions and categories!
Next: building custom views, forms, and templates.
Top comments (0)