title: Django Passing Custom Form Parameters to Formset
body: <blockquote>
    <p>This was fixed in Django 1.9 with <a href="https://docs.djangoproject.com/en/1.9/topics/forms/formsets/#passing-custom-parameters-to-formset-forms" rel="noreferrer">form_kwargs</a>.</p>
  </blockquote>
  
  <p>I have a Django Form that looks like this:</p>
  
  <pre><code>class ServiceForm(forms.Form):
      option = forms.ModelChoiceField(queryset=ServiceOption.objects.none())
      rate = forms.DecimalField(widget=custom_widgets.SmallField())
      units = forms.IntegerField(min_value=1, widget=custom_widgets.SmallField())
  
      def __init__(self, *args, **kwargs):
          affiliate = kwargs.pop('affiliate')
          super(ServiceForm, self).__init__(*args, **kwargs)
          self.fields["option"].queryset = ServiceOption.objects.filter(affiliate=affiliate)
  </code></pre>
  
  <p>I call this form with something like this:</p>
  
  <pre><code>form = ServiceForm(affiliate=request.affiliate)
  </code></pre>
  
  <p>Where <code>request.affiliate</code> is the logged in user. This works as intended.</p>
  
  <p>My problem is that I now want to turn this single form into a formset. What I can't figure out is how I can pass the affiliate information to the individual forms when creating the formset. According to the docs to make a formset out of this I need to do something like this:</p>
  
  <pre><code>ServiceFormSet = forms.formsets.formset_factory(ServiceForm, extra=3)
  </code></pre>
  
  <p>And then I need to create it like this:</p>
  
  <pre><code>formset = ServiceFormSet()
  </code></pre>
  
  <p>Now how can I pass affiliate=request.affiliate to the individual forms this way?</p>