title: Cant upload Image with CreatView Django
body: <blockquote>
  <p>views.py</p>
  </blockquote>
  <pre><code>class PostCreatView(LoginRequiredMixin, CreateView): 
     model = Posts
     fields = ['image', 'caption']
     template_name = 'home/creat-post.html'
     success_url = '/home/'
  
     def form_valid(self,form):
        form.instance.user = self.request.user
        return super().form_valid(form)
  </code></pre>
  <blockquote>
  <p>models.py</p>
  </blockquote>
  <pre><code>    class Posts(models.Model):
     caption = models.CharField(max_length=2200)
     date_posted = models.DateTimeField(default=timezone.now())
     image = models.ImageField( upload_to='PostsImages')
     user = ForeignKey(User,  on_delete=models.CASCADE ,related_name='UserPosts')
  
     def __str__(self):
        return f&quot;Post {self.id} ({self.user.username})'s&quot;
  
     def save(self, *args, **kwargs):
        super().save(*args, **kwargs)
        img = Image.open(self.image.path)
        #img = make_square(img, 1080, 1080)
        img.save(self.image.path) 
  
     class Meta:
        ordering = ['-date_posted']
  </code></pre>
  <blockquote>
  <p>creat-post.html</p>
  </blockquote>
  <pre><code>{% extends &quot;home/base.html&quot; %}
  {% load crispy_forms_tags %}
  {% block content %}
     &lt;div&gt;
        &lt;form method=&quot;POST&quot;&gt;
           &lt;fieldset&gt;
              &lt;legend &gt;Creat Post&lt;/legend&gt;
              {% csrf_token %}
              {{ form|crispy }}
           &lt;/fieldset&gt;
           &lt;button class=&quot;btn btn-primary&quot; type=&quot;submit&quot;&gt;Post&lt;/button&gt;
        &lt;/form&gt;
  
     &lt;/div&gt;
  {% endblock %}
  </code></pre>
  <blockquote>
  <p>So I created a creatview to add create new post. However when I go to the link and add photo then hit submit, it gives me as I haven't uploaded an image.
  <a href="https://i.stack.imgur.com/FS9FI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FS9FI.png" alt="Here is what I see after adding an image and submitting it" /></a></p>
  </blockquote>
  <p>However, I am able to add images to a new Post from the admin normally.</p>