﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16446	A WizardView with a step containing a formset generated by inlineformset_factory will always fail	guillaume@…	nobody	"A WizardView with a step containing a formset generated by inlineformset_factory will always fail.

Indeed inline formset use BaseInlineFormSet class and Forwizard in the method get_form call the instance with the parameter ""initial"", and the BaseInlineFormSet class doesn't take initial as a parameter.

The solution I have is to create a custom class which inherits from BaseInlineFormSet and take initial as parameter:

{{{#!python
class BaseInitialFormSet(BaseInlineFormSet):
    def __init__(self, *args, **kwargs):
        """"""
        Grabs the curried initial values and stores them into a 'private'
        variable. Note: the use of self.__initial is important, using
        self.initial or self._initial will be erased by a parent class
        """"""
        self.__initial = kwargs.pop('initial', [])
        super(BaseStockFormSet, self).__init__(*args, **kwargs)

#    def total_form_count(self):
#        return len(self.__initial) + self.extra

    def _construct_forms(self):
        return super(BaseStockFormSet, self)._construct_forms()
        #return formsets.BaseFormSet._construct_forms(self)

    def _construct_form(self, i, **kwargs):
        if self.__initial:
            try:
                kwargs['initial'] = self.__initial[i]
            except IndexError:
                pass
        return super(BaseStockFormSet, self)._construct_form(i, **kwargs)
}}}

And the use inlineformset_factory with formset=BaseInitialFormSet parameter.
"	Bug	closed	Forms	dev	Normal	duplicate			Unreviewed	0	0	0	0	1	0
