title: Django forms. TypeError: __init__() got an unexpected keyword argument 'instance'
body: <p>I keep getting error messages and have no idea why. I think it has to do with the variable for instance, but i see a lot of examples all over the internet that work the same way.</p>
  
  <p>models.py</p>
  
  <pre><code>class Establishments(models.Model):
      title = models.CharField(max_length=255)
      town = models.ForeignKey(Town, on_delete=SET_NULL, null=True)
      addrstreet = models.CharField(max_length=255)
      addrzip = models.CharField(max_length=12)
      telephone = models.CharField(max_length=15)
      email = models.CharField(max_length=255)
      chamberofcomnr = models.CharField(max_length=25)
      description = models.TextField(max_length=255)
      website =  models.CharField(max_length=255)
      categorie = models.ForeignKey(Establishmentcategory, on_delete=SET_NULL, null=True)
      pub_date = models.DateTimeField('date published')
      drupuser = models.ForeignKey(Drupalusers, on_delete=SET_NULL, null=True)
      druppublished = models.BooleanField()
      drupurl = models.CharField(max_length=255)
      drupnodeid = models.IntegerField()
      def __str__(self):
          return self.title
  class Impcalendar(models.Model):
      establishment = models.ForeignKey(Establishments, on_delete=SET_NULL, null=True)
      active = models.BooleanField()
      prio = models.IntegerField()
      url = models.CharField(max_length=255)
      check_intervalh = models.IntegerField()
      check_fixedh = models.IntegerField()
      log = models.BooleanField()
      cuttag = models.CharField(max_length=255)
      cuttxt =  models.CharField(max_length=255)
      cuttxtend = models.CharField(max_length=255)
      comment = models.CharField(max_length=255)
      page = models.TextField()
      pageold = models.TextField()    
      change = models.TextField()
      pagedate = models.DateTimeField()
      pagedatenext = models.DateTimeField()
      status = models.IntegerField()
      errors = models.IntegerField()
      def __str__(self):
          return str(self.id)
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>path('calendar/&lt;int:calendar_id&gt;/', views.calendaredit, name='calendaredit')
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def calendaredit(request, calendar_id):
      calendar = get_object_or_404(Impcalendar, pk=calendar_id)
      print (calendar.url)
      form = ImpcalendarForm(request.POST or None, instance=calendar)
      # if this is a POST request we need to process the form data
      if request.method == 'POST':
          # create a form instance and populate it with data from the request:
          print (form.url)
          # check whether it's valid:
          if form.is_valid():
              #calendar.establishment = form.cleaned_data['
              calendar = form.save(commit=false)
              calendar.active = form.cleaned_data['active']
              calendar.save()
              return redirect('handmatig')
  
  return render(request, 'import_calendar/handmatig_edit.html', {'form': form})
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>class ImpcalendarForm(forms.Form):
      establishment = forms.ModelChoiceField(queryset = Establishments.objects.all())
      page = forms.CharField(widget=forms.Textarea)
      pageold = forms.CharField(widget=forms.Textarea)
      change = forms.CharField(widget=forms.Textarea)
      class Meta:
          model = Impcalendar
          fields = '__all__'
  </code></pre>
  
  <p>So i want to have a record page, listing all the records already works, where i can edit the form. It needs to show the record as a Django form. It crashes on the line;
      form = ImpcalendarForm(request.POST or None, instance=calendar)</p>
  
  <p>If i print the variable calendar or calendar.url i get the correct data. 
  The error message is;</p>
  
  <pre><code>TypeError: __init__() got an unexpected keyword argument 'instance'
  </code></pre>
  
  <p>Spend a week debugging. Now escalading. ;-) </p>