Django Admin Inlines - Custom Shortcuts?

This is kind of a dumb question, but I have a couple of models that have many-to-many relationships, and I use Inline to allow the administration of these models in Django Admin. The shortcuts that are shown for these lines do not seem to be affected by Model Meta attributes at all, such as other Admin sections. The admin interface will be used by non-programmers, and I would prefer that they don’t have to look at sections with labels such as “user function relations” that contain lines called “User_feature objects”. Is this a way to change them?

+3
source share
1 answer

Django automatically creates an intermediate model for the m2m relationship and creates a detailed name as "% (from) s -% (to) s ratio", marked for translation. You can use a more appropriate translation to influence the change throughout the site. Gettext definition for search:

'%(from)s-%(to)s relationship'
'%(from)s-%(to)s relationships'

You can override the automatically generated verbose_name and verbose_name_plural for AdminInline, which controls the many-to-many relationship:

class CategoryInline(admin.TabularInline):
    model = BaseProduct.categories.through
    verbose_name = "Category item"
    verbose_name_plural = "Category items"

To define a unicode method, see the answer with published solutions for using a proxy model and a monkey patch unicode .

Django: Friendier header for StackedInline for auto generated through model?

+11
source

All Articles