I have a modelformset that I've created in a view as such:
CarpoolFamilyInviteModelFormset = modelformset_factory(CarpoolFamilyInvite, fields=('family_name','family_email'), extra=3)
As you can see, I've tried to limit it to two fields: family_name and family_email. However, when I render it in the template, I get an extra field, ID. Here's the template code:
{% for form in formset %}
<div class="row">
{% for field in form %}
<div class="span3">
<input id="focusedInput" class="input-large focused" type="text" placeholder="{{ field.label }}">
</div>
{% endfor %}
</div>
{% endfor %}
and here's what the form looks like:
Any idea how I can skip showing the ID fields? exclude="ID" doesn't seem to have any effect. THanks!
The model formset relies on the id field, so it is not possible to exclude it.
The best option is to render the id field as a hidden field. See the docs for looping over hidden and visible fields for an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With