I am using model form set. If i use formset_factory then its displaying the form like this which is correct but if i use modelformset_factory then its displaying all the objects from model like this . It should be. Am I missing something? thanks
form
class MyImageForm(ModelForm):
class Meta:
model = MyImage
exclude = ('test', 'user')
MyImageFormSet = modelformset_factory(MyImage, MyImageForm)
template
{% for form in formset %}
{{ form.non_field_errors }}
<tr>
<td>{{ form.image }}</td>
<td></td>
</tr>
{% endfor %}
{{ formset.management_form }}
According to the Django documentation on modelformset, you can create MyImageFormSet as you have been doing, but simply filter it afterwards (and presumably return the new modelformset).
Create the modelformset as normal:
But use the modelformset with an empty query, like this: