title: How download image from URL to django?
body: <p>I want to load an image by URL, but only the URL itself is saved to the model, how can I specify the path to save to the media folder, and how do I save it at all?</p>
  <pre><code>from django.db import models
  import urllib.request
  from urllib.parse import urlparse
  
  upload_path = 'media/'
  
  class Image(models.Model):
      image = models.ImageField(upload_to=upload_path, null= True, blank=True)
      image_url = models.URLField(blank=True, null=True)
  
      def get_image(self):
          name = urlparse(str(self.image)).path.split('/')[-1]
          urllib.request.urlretrieve(str(self.image_url), 'img\media\media' + name + '.jpg')
  </code></pre>