Add `help_text` to Django Admin field

I am trying to display an image while editing a user in the admin panel, but I cannot figure out how to add the help text.

I am using this Django Admin Show Image from Imagefield which works great.

However, the attribute short_description

only names the image and help_text

doesn't seem to add text below it.

How to add help_text

to this field, for example, in normal model fields?

EDIT:

I would like to have help_text

in the image, like the password field in this screenshot:

screenshot of admin page

+3


source to share


1 answer


Use a custom form if you don't want to change the model:



from django import forms

class MyForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super(MyForm, self).__init__(*args, **kwargs)
        self.fields['image'].help_text = 'My help text'

    class Meta:
        model = MyModel
        exclude = ()

@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
    form = MyForm
    # ...

      

+3


source







All Articles