B
B
Bjornie2017-08-02 11:31:29
Django
Bjornie, 2017-08-02 11:31:29

How to set an arbitrary name for the __str__ column in the admin panel?

In admin.py :

class DeviceAdmin(admin.ModelAdmin):
    list_display = ('__str__', 'category', 'owner_id')

For the __str__ column, I get the name of the class (DEVICE). And you need something verbose_name, which are written in the fields of models in models.py , i.e. set an arbitrary field/column name.
Tell me how it's done?
PS Is it necessary to register this class in admin.py, and then pass it to admin.site.register(Device, DeviceAdmin), or can it somehow be done directly in models.py?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question