1👍
✅
To solve this problem you basically have three options:
-
Create your own renderer, and use it as argument for
ChoiceField
, unfortunately you will need to create it from scratch, since django doesn’t allow you to simply overrideRadioFieldRenderer
class. https://github.com/django/django/blob/1.5.4/django/forms/widgets.py#L693 -
Just loop over your choices and use manually created radio input tags, there’s not a lot of validation to do and retrieving selected item or model object is also simple enough.
-
The simplest and less recommended way could be to include the whole image tag inside label string (use settings to get media url part).
Source:stackexchange.com