﻿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
25880	Forms created by formset_factory's extra parameter don't have instance set	karyon	Parth Patil	"i have code of the following form:


{{{

Model A:
    pass

Model B:
    related_field = ForeignKey(A)


class BForm(ModelForm):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        print(self.instance.related_field)


def some_view(request):
    InlineBFormset = inlineformset_factory(A, B, formset=ABFormset, form=BForm, extra=1)

    formset = InlineBFormset(request.POST or None, instance=some_a_instance)


}}}

the line with the print crashes for the form created by the extra=1 with RelatedObjectDoesNotExist: B has no A. i would have expected that the some_a_instance is set on the form's self.instance.

in django 1.9, i can easily work around that by handing over constructor parameters, but it would still seem weird to me to hand over the related instance that would later be set by the formset's save method anyways.

i can provide the real code if needed."	Cleanup/optimization	assigned	Forms	1.8	Normal			johannes.linke@…	Accepted	0	1	0	0	0	0
