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

Conversation

@jmahmood
Copy link

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!

(inlineforms are not passed querysets but rather a base object from which
to fetch related objects.)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant