django-formwizard icon indicating copy to clipboard operation
django-formwizard copied to clipboard

Enabled use of BaseInlineForm in formwizard

Open jmahmood opened this issue 13 years ago • 0 comments

When passing an inline form (generated by inlineformset_factory), formwizard would crash with a "invalid keyword: "initial") error.

inlineformset_factory produces a BaseInlineFormSet that is derived from BaseModelFormSet. Unfortunately, it needs an "initial" object as opposed to a QuerySet to be properly initialized.

A quick example of how it may be used is as follows:

recipe = Recipe.objects.get(pk=recipe_id)
initial = {
    '0':recipe.recipe_creator,
    '1':recipe,
    '2':recipe,
}
view = RecipeWizard.as_view([RecipeCreatorForm,RecipeBase, inlineformset_factory(Recipe, RecipeStep))

There is more information about inlineformset_factory here: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/

First time I'm doing this, apologies in advance if there is any etiquette violations above. If you need anything else, please feel free to let me know so I can provide it. Thank you!

jmahmood avatar Nov 25 '11 05:11 jmahmood