title: IntegrityError in Django even after defining form_valid
body: <p>I'm trying to create and store the model form in the database. The model represents a product, and has field like the category, image, price... etc.</p>
  
  <p>Here's the model</p>
  
  <pre class="lang-py prettyprint-override"><code>class Product(models.Model):
      categories = (("Books", "Books/Study Materials"),
                    ("Notebooks", "Notebooks/Rough Pads"),
                    ("Equipments", "Equipments/Tools"),
                    ("Cloths", "Cloths/Uniforms"),
                    ("Sports", "Sports/Sportswear"),
                    ("Miscellaneous", "Miscellaneous"))
  
      user = models.ForeignKey(User, on_delete = models.CASCADE)
      date_posted = models.DateTimeField(default = timezone.now)
      category = models.CharField(max_length = 13, choices = categories, default = "Miscellaneous")
      description = models.CharField(max_length = 75, null = True, blank = True)
      image = models.ImageField(default = "product/default.png", upload_to = "product")
      price = models.PositiveIntegerField()
  
      def __str__(self):
          return f"{self.category} by {self.user.username} for {self.price}"
  
      def save(self, *args, **kwargs):
          super().save()
  
          image = Image.open(self.image.path)
          image.thumbnail((600, 600), Image.ANTIALIAS)
          image = image.crop(((image.width - 600)//2, (image.height - 400)//2, (image.width + 600)//2, (image.height + 400)//2))
          image.save(self.image.path)
  </code></pre>
  
  <p>Here's the form that same model</p>
  
  <pre class="lang-py prettyprint-override"><code>class ProductAddForm(forms.ModelForm):
      description = forms.CharField(max_length = 75, widget = forms.TextInput(attrs = {'placeholder': 'Description'}), help_text = "Not more than 75 characters")
      image = forms.ImageField(required = False)
      price = forms.IntegerField(required = False, widget = forms.TextInput(attrs = {'placeholder': 'Price'}))
  
      class Meta:
          model = Product
          fields = ('category', 'description', 'image', 'price')
  
      def clean_description(self, *args, **kwargs):
          description = self.cleaned_data.get('description')
          if len(description) == 0:
              raise forms.ValidationError('Description is required!')
          if len(description) &gt; 75:
              raise forms.ValidationError(f'Description should contains at most 75 characters, but bot {len(description)} characters!')
          return description
  
      def clean_price(self, *args, **kwargs):
          price = self.cleaned_data.get('price')
          if len(str(price)) == 0:
              raise forms.ValidationError('Product price is required!')
          elif price &lt; 0:
              raise forms.ValidationError('Negative price..... seriously?')
          return price
  </code></pre>
  
  <p>And below is the view I'm creating using django's generic CreateView</p>
  
  <pre class="lang-py prettyprint-override"><code>class product_add(CreateView):
      model = Product
      form_class = ProductAddForm
      template_name = 'Product/product_add.html'
  
      def form_valid(self, form, *args, **kwargs):
          form.instance.author = self.request.user
          return super().form_valid(form)
  </code></pre>
  
  <p>Above I'm defining the <code>form_valid</code> method to set the user of the product as the current user.
  But when submitting the form, the error still says-</p>
  
  <pre><code>IntegrityError at /product/add/
  NOT NULL constraint failed: Product_product.user_id
  </code></pre>
  
  <p>And even if I don't define the <code>form_valid</code> I'm still getting the same error!</p>
  
  <p>The error is at <code>super.save()</code>, and it says <code>Error in formatting: RelatedObjectDoesNotExist: Product has no user.</code></p>