Skip to content
This repository was archived by the owner on Dec 23, 2018. It is now read-only.

Enabled use of BaseInlineForm in formwizard #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions formwizard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,14 @@ def get_form(self, step=None, data=None, files=None):
if issubclass(self.form_list[step], forms.ModelForm):
# If the form is based on ModelForm, add instance if available.
kwargs.update({'instance': self.get_form_instance(step)})
elif issubclass(self.form_list[step], forms.models.BaseInlineFormSet):
# BaseInlineFormSet is based on ModelFormSet but has some significant differences.
# It breaks if initial is passed.
# Furthermore, you need to pass it an instance from which
# it gets the relationship needed, not a queryset.
# See Inline Formset docs here: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
del(kwargs['initial'])
kwargs.update({'instance': self.get_form_instance(step)})
elif issubclass(self.form_list[step], forms.models.BaseModelFormSet):
# If the form is based on ModelFormSet, add queryset if available.
kwargs.update({'queryset': self.get_form_instance(step)})
Expand Down