2👍
✅
In order to change how Django renders list items you need to override that field’s widget.
See the Customizing widget instances in the documentation.
And Overriding the default field types or widgets.
Finally, if this doesn’t give you enough control, you can write your own custom widget. Here is an example of a custom widget for working with key-value pairs. However, the only part you should be concerned with is the render()
method. You could extend a built in list widget, override the render()
method and make it spit out the html you want.
13👍
I suppose you could construct the html yourself.
<select name="{{ form.island_group.name }}">
{% for instance in form.island_group.field.queryset %}
<option value="{{ instance.pk }}">{{ instance.name }} yarr</option>
{% endfor %}
</select>
- [Django]-Django – Establishing Many To Many Relationship Between 2 Models Without Through Table Using Formsets
- [Django]-Increasing number of initial forms in a Django formset based on data in POST?
- [Django]-Create a facebook notification with Django package facepy : [15] (#15) This method must be called with an app access_token
- [Django]-Django Import Issue
- [Django]-Django can not delete csrftoken after logout
Source:stackexchange.com