Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label name for ModelAdmin in Django

Tags:

python

django

how can I give this class a label which is shown in the backend instead of "EditedAddress"?

class EditedAddressAdmin(admin.ModelAdmin):
    list_display = ('comp_name','fam_name', 'fon')
    search_fields = ['fam_name','comp_name']


admin.site.register(EditedAddress,EditedAddressAdmin)
like image 651
Jurudocs Avatar asked Mar 14 '13 20:03

Jurudocs


People also ask

What is verbose name Django?

verbose_name is a human-readable name for the field. If the verbose name isn't given, Django will automatically create it using the field's attribute name, converting underscores to spaces. This attribute in general changes the field name in admin interface.

What is admin panel in Django?

One of the most powerful parts of Django is the automatic admin interface. It reads metadata from your models to provide a quick, model-centric interface where trusted users can manage content on your site. The admin's recommended use is limited to an organization's internal management tool.

Where is Django admin template?

The default templates used by the Django admin are located under the /django/contrib/admin/templates/ directory of your Django installation inside your operating system's or virtual env Python environment (e.g. <virtual_env_directory>/lib/python3. 5/site-packages/django/contrib/admin/templates/ ).

What is the purpose of the admin site in a Django project?

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.


1 Answers

You can adjust the way your model name is displayed by adding a verbose_name and/or verbose_name_plural to your model:

class EditedAddress(models.Model):
    class Meta:
        verbose_name = 'Edited Address'
        verbose_name_plural = 'Edited Addresses'
like image 190
Brandon Avatar answered Oct 02 '22 09:10

Brandon