In django admin, If we define an element for list_display we can assign short_description
for that field as
class PersonAdmin(admin.ModelAdmin): list_display = ('upper_case_name','age') def upper_case_name(self, obj): return ("%s %s" % (obj.first_name, obj.last_name)).upper() upper_case_name.short_description = 'Name'
But what if I would like to change short description of age field ? I would like to show the header of Age
field as Person's Age
instead Age
. Of course, I can write custom functions as upper_case_name
for each field but it is a bad solution I think.
Could you suggest me any easy way to do this ? Thanks
It provides a simple UI for creating, editing and deleting data defined with the Django ORM. In this article we are going to enable the admin user interface for a simple model and customize it from a simple list view to a more user friendly table like interface.
To login to the site, open the /admin URL (e.g. http://127.0.0.1:8000/admin ) and enter your new superuser userid and password credentials (you'll be redirected to the login page, and then back to the /admin URL after you've entered your details).
To view the default admin template you can access it in the django/contrib/admin/templates/admin folder. In this situation you will most likely be using a virtual environment and can find this folder in the directory that contains all the installed libraries.
Django provides a built-in admin module which can be used to perform CRUD operations on the models. It reads metadata from the model to provide a quick interface where the user can manage the content of the application. This is a built-in module and designed to perform admin related tasks to the user.
There are 2 model field options that provide descriptions to users: verbose_name and help_text. Using verbose names seems to be suitable in your case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With