title: How to resize an ImageField image before saving it in python Django model
body: <p>I am trying to implement a Django ImageField class function for resizing images however I am not certain where this function accepts my new image dimensions</p>
  
  <p>Running on Linux and Python 3.7</p>
  
  <p>I've had a look at this documentation, but can't quite make sense of it:
  <a href="https://docs.djangoproject.com/en/1.11/_modules/django/db/models/fields/files/#ImageField" rel="noreferrer">https://docs.djangoproject.com/en/1.11/_modules/django/db/models/fields/files/#ImageField</a></p>
  
  <p>I'd really appreciate it if someone can show me an example of how to use this function. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I haven't successfully managed to resize my image dimensions yet, which is what i am trying to achieve. How may I resize this image before I save it given it is being fetched by <code>ImageField</code> (I found the <code>update_dimensions_fields</code> class function for <code>ImageField</code> however i cant figure out how to use it)</p>
  
  <pre class="lang-py prettyprint-override"><code>class Posts(models.Model):
      title = models.CharField(max_length=200, blank=True)
      body = models.TextField(blank=True)
      created_at = models.DateTimeField(default=datetime.datetime.now)
      post_image = models.ImageField(upload_to=get_image_path, blank=True, null=True)
  
      def __str__(self):
          return self.title
  
      def save(self, *args, **kwargs):
          # I would like to use the function beneath to resize my images before I save them to my database
          self.post_image.update_dimension_fields(self, instance, force=False, *args, **kwargs)
  
          super().save(*args, **kwargs) # Call the "real" save() method.
  
      class Meta:
          verbose_name_plural = "Posts"
  
  </code></pre>