def make_user_parameter_formset(user, extra=3):
    class _UserParameterCreateForm(forms.ModelForm):
        class Meta:
            model = UserParameter
            fields = ['data_type', 'name', 'value', 'owner', ]
            widgets = {
                'data_type': forms.Select(attrs={'class': 'form-control', }),
                'name': forms.TextInput(attrs={'class': 'form-control', }),
                'value': forms.TextInput(attrs={'class': 'form-control', }),
                'owner': forms.HiddenInput(),
            }

        def __init__(self, *args, **kwargs):
            # user = kwargs.pop('user')
            super(_UserParameterCreateForm, self).__init__(*args, **kwargs)
            self.fields['owner'].initial = user

    return modelformset_factory(UserParameter, form=_UserParameterCreateForm, extra=extra, can_delete=True)
This is a workaround for passing custom parameters (the parameter owner in our case)
dataset/ETHPy150Open 3bot/3bot/threebot/forms.py/make_user_parameter_formset