﻿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
11616	Ability add filter to inlineformset_factory	Marcel van Eck <vaneck.marcel@…>	nobody	"When using inlineformset_factory it would be helpful if an optional filter can be provided to limit the rows returned into the inline formset.

In some situations you want to limit the data to be edited in the form to a subset of the header record.
The example below limits the rows on the inline formset only to lines were the status is open.

{{{
mainform    = Form(instance=data)
formset1    = InlineFormSet1(instance=data, prefix=""inline1"", filter=""status='open'"")
}}}

As the formset is built, in addition to the foreign key set to the instance id the queryset (qs) is also limited to whatever is provided in filter.
Addition looks a little like below (plus some more code).
{{{
# __init__ in class BaseInlineFormset
qs = self.model._default_manager.filter(**{self.fk.name: self.instance}, filter)
}}}
"		closed	Forms			duplicate	inlineformset_factory		Unreviewed	0	0	0	0	0	0
