[Fixed]-How to programmatically access {{ form.my_field.id_for_label }}?

1👍

You can contruct it yourself like this:

for key, value in self.fields.items():
     value.widget.attrs.update({'class': 'form-control'})

     if value.help_text:
         django_id_for_label = self.auto_id % key  # self.auto_id == 'id_%s'
         my_id_for_label = '{}Help'.format(django_id_for_label)
         value.widget.attrs.update({'aria-describedby': my_id_for_label})
👤nik_m

Leave a comment