Opened 14 years ago
Closed 14 years ago
#14379 closed (invalid)
formset.is_bound returns False for ModelFormsets created with queryset as argument
Reported by: | Jannis Vajen | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
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 |
Description
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 False >>> formset.forms[0].is_bound False >>> formset.forms[0].instance Testobject object
Note:
See TracTickets
for help on using tickets.
This is correct behavior - instantiating
ModelFormSet
with a queryset is the equivalent of supplyinginitial
to aForm
which also isn't bound in that case.