Additional variable passed to django formset
<p>I have a quite peculiar issue, regarding creating a formset out of a certain form. The thing is, that the form has to has an undisclosed number of fields, so I want to pass a variable to that form, which will take a proper model from database, and create proper fields within form's <strong>init</strong> method.</p>

<pre><code>StrangeForm(forms.Form):
    def __init__(self, id, *args, **kwargs):
        super(StrangeForm, self).__init__(*args, **kwargs)
        # get the form's base entry
        self.certain_entry = Certain_Entry.objects.get(id=id)
        # create a hidden input to keep the id
        self.fields["id"] = forms.HiddenInput()
        self.fields["id"].initial = id
        # initiate text field
        self.fields["text_field"] = forms.CharField(widget=forms.TextInput(attrs={'style': 'width:95%', }),
                                                 required=False)
        self.fields["text_field"].initial = self.certain_entry.text
        # create and initiate fields for undisclosed number of subentries
        subordinates = Certain_Entry_Subordinates.objects.filter(foreign_key=self.certain_entry)
        for each in subordinates:
            the_name = "%d_%s_%s" % (each.further.id, each.further.name)
            self.fields[the_name] = forms.ChoiceField(choices=(("Ok", "Ok"), ("Not Ok", "Not Ok"), ("Maybe" "Maybe"),
                                                      required=False)
            self.fields[the_name].initial = each.option
</code></pre>

<p>The models are as follows:</p>

<pre><code>class Certain_Entry(models.Model):
    text = models.TextField(max_length=128, null=True, blank=True)

class Certain_Entry_Subordinates(models.Model):
    certain_entry = models.ForeignKey(Certain_Entry, null=False, blank=False)
    option = models.TextField(max_length=8, null=True, blank=True)
    further = models.ForeignKey(Further, null=False, blank=False)

class Further(models.Model):
    name = models.TextField(max_length=32, null=True, blank=True)
</code></pre>

<p>So as you see, I need to pass this ID into the form. When it's a single form, it's all OK, but I can't find any information as to how create a formset with forms that require a variable. Any ideas?</p>

<p>PS: As to WHY... Don't ask, I just need to do it that way, trust me. I'm an engineer.</p>