I have multiple admin sites, so different users get a different experience of editing the objects in the database. Each admin site has a different set of objects exposed, and a different styling. All of this can be done by overriding templates and ModelAdmin objects.
I can't work out how to provide different help_text through the different sites. help_text is always taken straight from the model field definition, and there doesn't seem to be a way to override it.
Am I missing something, or is this impossible?
An alternative way is to pass help_texts keyword to the get_form method like so:
def get_form(self, *args, **kwargs):
help_texts = {'my_field': 'Field explanation'}
kwargs.update({'help_texts': help_texts})
return super().get_form(*args, **kwargs)
The help_texts keyword gets eventually passed to the modelform_factory method and rendered as the standard help text from a model in the Django admin.
In case you're using an InlineModelAdmin, you need to override get_formset in the same manner.
This also works if you have readonly_fields in your ModelAdmin subclass.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With