title: How to fix modelformset error: __init__() missing 1 required positional argument: 'user'
body: <p>This is my first attempt at using formsets and I am stuck with this error.  Where am I going wrong? I don't fully understand how this works yet. I think my form is expecting a user but I don't know what to do with it. Thanks for any help!</p>
  
  <p><strong>error:</strong></p>
  
  <p><strong>init</strong>() missing 1 required positional argument: 'user'</p>
  
  <p><strong>model:</strong></p>
  
  <pre><code>class PropertySubmission(models.Model):
  
  BANNER_CHOICES = (
      ('NB', 'No Banner'),
      ('FL', 'For Lease'),
      ('FS', 'For Sale'),
      ('NL', 'New Listing'),
      ('SD', 'Sold'),
      ('LD', 'Leased'),
      ('RD', 'Reduced'),
      ('NP', 'New Price'),
      ('SC', 'Sold Conditionally'),
      ('CB', 'Custom Banner'),
  )
  
  image = models.ImageField(upload_to=user_directory_path, blank=True)
  mls_number = models.CharField(max_length=8, blank=True)
  headline = models.CharField(max_length=30)
  details = RichTextField()
  banner = models.CharField(max_length=2, choices=BANNER_CHOICES)
  author = models.ForeignKey(User, on_delete=models.CASCADE)
  date_posted = models.DateTimeField(default=timezone.now)
  date_modified = models.DateTimeField(default=timezone.now)
  program_code = models.ManyToManyField(Program)
  product = models.ForeignKey('Product', on_delete=models.SET_NULL, null=True)
  production_cycle = models.ManyToManyField('ProductionCycle')
  shell = models.ForeignKey('Shell', on_delete=models.SET_NULL, null=True)
  card_delivery_instructions = models.CharField(max_length=1000, blank=True)
  card_delivery_instructions_image = models.ImageField(upload_to=card_delivery_instructions_image_path, blank=True)
  </code></pre>
  
  <p><strong>form:</strong></p>
  
  <pre><code>class PropertyCreateKeepInTouchForm(forms.ModelForm):
  
  class Meta:
      model = PropertySubmission
      fields = ['headline','details','banner','image','mls_number','program_code']
      help_texts = {
          'details': '110 characters maximum',
  
      }
  
  def clean(self):
      cleaned_data = super().clean()
      image = cleaned_data.get("image")
      mls_number = cleaned_data.get("mls_number")
      program_code = cleaned_data.get("program_code")
  
      if mls_number == '' and image is None:
          # Only do something if one field are valid so far.
          self.add_error('image', 'Please provide an image or MLS number')
          self.add_error('mls_number', 'Please provide an image or MLS number')
          raise forms.ValidationError("Please provide a number")
  
      if program_code is None:
          self.add_error('program_code', 'Please select one or more programs')
          raise forms.ValidationError("Please select one or more program")
  
  def __init__(self, user, *args, **kwargs):
      super(PropertyCreateKeepInTouchForm, self).__init__(*args, **kwargs)
  
      #self.fields['details'].widget = forms.Textarea(attrs={'rows':4, 'cols':15, 'maxlength':110})
      self.fields['details'].label = "Provide Feature Property Details:"
      self.fields['program_code'].widget = forms.CheckboxSelectMultiple()
      self.fields['program_code'].queryset = Program.objects.filter(client=user).filter(production_cycles__product_name__name='Keep In Touch').filter(production_cycles__submission_deadline__lt=timezone.now()+timedelta(days=30)).filter(production_cycles__submission_deadline__gt=timezone.now()).distinct()
      self.fields['program_code'].label = "Select Programs"
      self.fields['mls_number'].label = "number - to retrieve a photo of the property."
      self.fields['image'].label = "Property Photo"
      self.fields['banner'].label = "Select a banner"
      self.fields['headline'].label = "Provide a headline"
  </code></pre>
  
  <p><strong>view:</strong></p>
  
  <pre><code>from django.forms import modelformset_factory
  @login_required
  def create_properties_keepintouch(request, num_forms):
  
  property_formset = modelformset_factory(PropertySubmission, form=PropertyCreateKeepInTouchForm, extra=1)
  
  formset = property_formset(queryset=PropertySubmission.objects.none())
  
  return render(request, 'programs/property_submission_create_formset.html', {'formset': formset, 'num_forms':num_forms})
  </code></pre>
  
  <p><strong>template:</strong></p>
  
  <pre><code>&lt;form class="form-horizontal" method="POST" action=""&gt;
  {% csrf_token %}
  {{ formset.management_form }}
  {% for form in formset %}
  &lt;div class="row form-row spacer"&gt;
  
  
      &lt;div class="col-6"&gt;
          &lt;hr&gt;
          &lt;div class="input-group"&gt;
  
              {{ form.media }}
              {{form.as_p}}
  
  
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  {% endfor %}
  &lt;div class="row spacer"&gt;
      &lt;div class="col-4 offset-2"&gt;
          &lt;button type="submit" class="btn btn-block btn-primary"&gt;Create&lt;/button&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>