0

Im using a custom/extended ModelMultipleChoiceField and ModelChoiceIterator as per the answer to another question here

https://stackoverflow.com/a/73660104/20600906

It works perfectly but Im trying to amend the template used to generate the groups to apply some custom styling - but after poking around everywhere I cant find anything to overwrite.

I have gone through all the template files in '\venv\Lib\site-packages\django\forms\templates\django\forms' and cannot find anything relating to the behaviour Im seeing on screen.

The 'groups' are wrapped in strong tags which is fine, but id like to find the file specifying this so I can overwrite with some bootstrap classes.

I've traced back through the class inheritance and the first widget specifiying a template is this one:

class Select(ChoiceWidget):
    input_type = "select"
    template_name = "django/forms/widgets/select.html"
    option_template_name = "django/forms/widgets/select_option.html"
    add_id_index = False
    checked_attribute = {"selected": True}
    option_inherits_attrs = False

Checking these files doesn't help as they don't appear to be the ones in use. Not sure where i'm going wrong?

Edit: Ive just realised the strong tags are coming from the cripsy forms tag. The templates probably make a lot more sense now, Ill go do some more digging.

Phear46
  • 15
  • 6
  • Does this answer your question? [Django widget override template](https://stackoverflow.com/questions/44675550/django-widget-override-template) – lucutzu33 Nov 28 '22 at 18:31

0 Answers0