How to set another Inline title in Django Admin?

PythonDjangoDjango ModelsDjango Admin

Python Problem Overview


I need to change the inline title to something else other than the verbose_name of the class Meta in the model. Is there an attribute to achieve this?

Python Solutions


Solution 1 - Python

As documented, you need to set the values of your InlineModelAdmin subclass:

InlineModelAdmin.verbose_name - An override to the verbose_name found in the model’s inner Meta class.

InlineModelAdmin.verbose_name_plural - An override to the verbose_name_plural found in the model’s inner Meta class.

In this example, instead of the title 'Device' we use 'Phone':

class DeviceInline(admin.TabularInline):
    model = Device
    verbose_name = "Phone"
    verbose_name_plural = "My Phones"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questioneos87View Question on Stackoverflow
Solution 1 - PythonodedfosView Answer on Stackoverflow