-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
if we had given a verbose name for the model field and if we try to customize our FK representation in the admin panel then we will use formfield_for_foreignkey as shown in the block below
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'category':
return CategoryChoiceField(queryset=Category.objects.all())
return super().formfield_for_foreignkey(db_field, request, **kwargs)and here it will neglect the given verbose name (tbh IDK why its happening maybe DB layer is overridden by the form layer!)
so we have to provide the label argument again
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'category':
return CategoryChoiceField(queryset=Category.objects.all(), label='_XYZ_')
return super().formfield_for_foreignkey(db_field, request, **kwargs)Metadata
Metadata
Assignees
Labels
No labels