by Kunal Sir
Admin Panel:
The Django admin application can use your models to automatically build a site area that
you can use to create, view, update, and delete records. This can save you a lot of time during
development, making it very easy to test your models and get a feel for whether you have the
right data.
Creating an admin panel in Django is quite straightforward and powerful due to Django's
built-in admin interface.
Steps to Create an Admin Panel in Django:
Step 1:- Create a Django App
If you haven't already, create a Django app using the command line:
django-admin startapp yourappname
Step 2:- Define Models
In your app's models.py file, define the models you want to manage via the admin panel:
Enter command in Terminal:
py manage.py makemigrations
py manage.py migrate
Stop, Near, 1st Floor, Above Rupam Sweets/ Priyanka Collections Building Vikas Mitra Mandal Chowk Road,
Karve Nagar, Pune, Maharashtra 411052 , Mobile No.- 8888022204
by Kunal Sir
Step3: - Register Models in Admin Panel
In the app's admin.py file, register your models to make them accessible in the admin
panel:
list_display to control which fields are displayed on the change list page of the admin. If you
don't set list_display, the admin site will display a single column that displays the __str__()
representation of each object.
The Django admin is an automatically-generated user interface for Django models. The register
function is used to add models to the Django admin so that data for those models can be
created, deleted, updated and queried through the user interface.
@admin.register(model_nm)
admin.site.register(model_nm,admin_nm)
Step 4:- Create Superuser
Run the following command to create a superuser who can access the admin panel:
python manage.py createsuperuser
Stop, Near, 1st Floor, Above Rupam Sweets/ Priyanka Collections Building Vikas Mitra Mandal Chowk Road,
Karve Nagar, Pune, Maharashtra 411052 , Mobile No.- 8888022204
by Kunal Sir
Step 5:- Start Development Server
python manage.py runserver
Step 6:- Access Admin Panel
Go to http://127.0.0.1:8000/admin/ in your browser and log in using the superuser
credentials created earlier.
You should now see the registered model(s) listed in the admin panel. You can add, edit, and
delete instances of these models via the web interface.
Stop, Near, 1st Floor, Above Rupam Sweets/ Priyanka Collections Building Vikas Mitra Mandal Chowk Road,
Karve Nagar, Pune, Maharashtra 411052 , Mobile No.- 8888022204
by Kunal Sir
Stop, Near, 1st Floor, Above Rupam Sweets/ Priyanka Collections Building Vikas Mitra Mandal Chowk Road,
Karve Nagar, Pune, Maharashtra 411052 , Mobile No.- 8888022204