[Solved]-Model "help" text in Django Inline Admin

4👍

If you’re not talking about specific help_text attribute then then look at this post it shows an underdocumented way of accomplishing this.

3👍

If you don’t want to mess around with getting the help_text information into the formset’s context and modify the edit_inline template, there is a way of capturing the verbose_name_plural Meta attribute of your model for that purpose.

Basic idea: If you mark that string as safe you can insert any html element that comes to your mind. For example an image element with it’s title set to global your model help text. This could look somethink like this:

class Meta:
    verbose_name = "Ygritte"
    verbose_name_plural = mark_safe('Ygrittes <img src="' + settings.STATIC_URL + \
                                    'admin/img/icon-unknown.svg" class="help help-tooltip" '
                                    'width="15" height="15" '
                                    'title="You know nothing, Jon Snow"/>')

Of course – this is kind of hacky – but this works quite simple, if your model is only accessed as an inline model and you don’t need the plural verbose name for other things (e.g. like in the list of models in your application’s admin overview).

👤ecp

Leave a comment