I’m using Django’s FormWizard. It works fine but I’m having trouble getting any empty model formset to display correctly.
I have a model called Domain. I’m creating a ModelFormset like this:
DomainFormset = modelformset_factory(Domain)
I pass this to the FormWizard like this:
BuyNowWizardView.as_view([DomainFormset])
I don’t get any errors but when the wizard renders the page, I get a list of all Domain objects. I’d like to get an empty form. How I can do this? I’ve read that I can give a queryset parameter to the ModelFormset like Domain.objects.none() but it doesn’t seem to work as I get errors.
Any ideas on where I’m going wrong?
Thanks
The Django docs give two ways to change the queryset for a formset.
The first way is to pass the queryset as an argument when instantiating the formset. With the formwizard, you can do this by passing
instance_dictThe second approach is to subclass
BaseModelFormSetand override the__init__method to use the empty queryset.You then pass
DomainFormSetto the form wizard as before.