You need to pass in a query set:
IPTCFormSet = modelformset_factory(IPTCForm)
formset = IPTCFormSet(queryset=IPTC.objects.all())
Domanda
When I create a form like this:
class IPTCForm(ModelForm):
class Meta:
model = IPTC
fields = ['creator', 'datetime_value', 'headline', 'caption', 'instructions']
[...]
form = IPTCForm(instance=iptcObj)
The form already is populated with values from the object.
But when I use it in a formset instead, all the values are gone:
IPTCFormSet = formset_factory(IPTCForm)
Why is this happening?
Soluzione
You need to pass in a query set:
IPTCFormSet = modelformset_factory(IPTCForm)
formset = IPTCFormSet(queryset=IPTC.objects.all())