Django admin by default is highly responsive GUI, which offers various features and an overall CRUD application to help developers and users. Moreover, Django admin can be customized to fulfill one’s needs such as showing fields on the home page of the table, etc. In this article, we will discuss how to enhance Django-admin Interface.
Project structure looks like:
Let us create an app called state which has one model with the same name(state). When we register app to admin.py it shows like.
Check it in the django admin interface
Now lets’ customize django admin according to available options.
Customize Django Admin Interface
1. Change model name:
If you want to change name of model which is States here so open model.py file and add verbose_name attribute in meta section.
2. By default django admin shows only object name in listing.
One can show multiple fields data from model. Add some lines of code in your admin.py file.
3. By default there is only one option which is delete option.
One can add more option on Action dropdown:
4. Disable Delete option:
5. Remove Add option:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.