Full Stack Development with Django
Django Admin Interface
When you start a project with Django it
also provides a default admin interface
that can be used to perform create, read,
update, and delete operations on the
model directly.
It reads a set of data that explains and
gives information about data from the
model.
Provides an instant interface where the
user can adjust the contents of the
application.
This is an in-built module designed to
Full Stack Development with Django
Full Stack Development with Django
Need of Django Admin Interface
Automatically build CRUD for models
Lot of repetitive tasks is avoided
Can be customized
It is an authentication based
dashboard which restricts to
privileged administrators
Has powerful features of search and
filter Dept. of AIML, JNNCE
Full Stack Development with Django
python [Link] createsuperuser
Dept. of AIML, JNNCE
Customizing the Admin Interface
Step 1
Set up the Admin Interface, it
involves following
Install Django (Pip Install)
Create Project
Create App
Add App to Installed apps
Step 2 Create Model
In your app directory their is file name called [Link].
In this file you can define the models that you want to manage
through admin Interface
from [Link] import models
class Book([Link]):
title = [Link](maxlength=300)
authors = [Link](Author)
publisher = [Link](Publisher)
publication_date = [Link]()
Step 3 Register Models with Admin
We Can easily register our model with admin through a
python file name Called [Link]
from [Link] import admin
[Link] import Book
[Link](Book)
Step 4 Create Superuser
python [Link] createsuperuser
Step 5 Create Superuser
[Link]
Step 6 Access the Admin Interface
Step 7 Customizing the Admin Interface
We can customize the models in admin interface by creating admin
class in [Link]
Example
from [Link] import admin
from [Link] import Book
class BookAdmin([Link]):
list_display = ('title', 'publisher', 'publication_date')
list_filter = ('publisher', 'publication_date')
ordering = ('-publication_date',)
search_fields = ('title’,)
[Link] (Book,BookAdmin)
Step 8 Admin Interface use
There are many options to maintain data active
Adding
Editing
Filtering
Searching
Managing records
Reason to use Admin Interface
It reads metadata from models to provide a quick, model centric
interface where trusted users can manage content on your site