I have a django modelform 'Recipe' with a foreignkey field to a model 'Ingredient'.
When rendering the form I get a SELECT list that have an ID matching the ingredients ID and text display equal to the string representation of the field.
However, I want to add a data-attribute to the select list that matches the rendered option from the Ingredient queryset.
For example, lets say this is what is currently being rendered:
<option value="1158">Carrots</option>
<option value="1159">Strawberry</option>
<option value="1160">Onion</option>
<option value="1161">Spinach</option>
But I want to add a data attribute for the related objects:
<option value="1158" data-ingredient-type="vegetable">Carrots</option>
<option value="1159" data-ingredient-type="fruit">Strawberry</option>
<option value="1160" data-ingredient-type="vegetable">Onion</option>
<option value="1161" data-ingredient-type="vegetable">Spinach</option>