Opened 8 years ago

Closed 8 years ago

#14379 closed (invalid)

formset.is_bound returns False for ModelFormsets created with queryset as argument

Reported by: Jannis Owned by: nobody
Component: Forms Version: master
Severity: Keywords: modelformset bound
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When a Modelformset is instantiated via a queryset, its is_bound attribute returns False although all of its forms are linked to instances of the queryset. This seems a bit odd to me because formset and forms are bound as soon as the Modelformset is instantiated via data (i.e. request.POST).

>>> from django.forms.models import modelformset_factory
>>> from models import Testobject

>>> TestFormset = modelformset_factory(Testobject)
>>> formset = TestFormset(queryset=Testobject.objects.all())

>>> formset.is_bound 
>>> formset.forms[0].is_bound
>>> formset.forms[0].instance
Testobject object

Change History (1)

comment:1 Changed 8 years ago by Honza Král

Resolution: invalid
Status: newclosed

This is correct behavior - instantiating ModelFormSet with a queryset is the equivalent of supplying initial to a Form which also isn't bound in that case.

Note: See TracTickets for help on using tickets.
Back to Top