python / beginner
Snippet
Registering Models in Django Admin
To manage your data through Django's built-in admin panel, you must register your models in the admin.py file of your app.
snippet.py
1
2
3
4
from django.contrib import adminfrom .models import Articleadmin.site.register(Article)
django
Breakdown
1
from django.contrib import admin
Imports the admin module from Django's core.
2
from .models import Article
Imports the Article model from the current app's models file.
3
admin.site.register(Article)
Registers the model so it appears and is editable in the admin interface.