Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin list_display short_description

Tags:

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

like image 609
brsbilgic Avatar asked Jul 25 '11 10:07

brsbilgic


People also ask

What is list_ display in Django?

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.

How do I access my Django admin page?

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).

Where is Django admin template?

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.

What is Django admin panel?

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.


1 Answers

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.

like image 66
shanyu Avatar answered Sep 20 '22 13:09

shanyu