DEV Community

Joe
Joe

Posted on

Django Admin: Powerful Data Management for Finance Apps

Django comes with a built-in admin interface—no coding required!


1. Create a Superuser

Run:

python manage.py createsuperuser
Enter fullscreen mode Exit fullscreen mode

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']
Enter fullscreen mode Exit fullscreen mode

3. Run the Server & Use Admin

python manage.py runserver
Enter fullscreen mode Exit fullscreen mode

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)