Django docs provide two ways to change the set of queries for a set of forms .
The first way is to pass the request as an argument when creating an instance of the form set. With formwizard you can do this by passing instance_dict
# set the queryset for step '0' of the formset instance_dict = {'0': Domain.objects.none()}
The second approach is to subclass BaseModelFormSet
and override the __init__
method to use an empty set of queries.
from django.forms.models import BaseModelFormSet class BaseDomainFormSet(BaseModelFormSet): def __init__(self, *args, **kwargs): super(BaseDomainFormSet, self).__init__(*args, **kwargs) self.queryset = Domain.objects.none() DomainFormSet = modelformset_factory(Domain, formset=BaseDomainFormSet)
Then you pass the DomainFormSet
to the form master, as before.
source share