SHARE
TWEET

Untitled

a guest May 20th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ValueError                                Traceback (most recent call last)
  2. <ipython-input-15-bed9a9f3e7b2> in <module>()
  3. ----> 1 user.primary_image.save("image.jpg", File(img_temp), save=True)
  4.  
  5. ~/Desktop/pyco/test/env/lib/python3.6/site-packages/django/db/models/fields/files.py in save(self, name, content, save)
  6.      84
  7.      85     def save(self, name, content, save=True):
  8. ---> 86         name = self.field.generate_filename(self.instance, name)
  9.      87         self.name = self.storage.save(name, content, max_length=self.field.max_length)
  10.      88         setattr(self.instance, self.field.name, self.name)
  11.  
  12. ~/Desktop/pyco/test/env/lib/python3.6/site-packages/django/db/models/fields/files.py in generate_filename(self, instance, filename)
  13.     300         """
  14.     301         if callable(self.upload_to):
  15. --> 302             filename = self.upload_to(instance, filename)
  16.     303         else:
  17.     304             dirname = datetime.datetime.now().strftime(self.upload_to)
  18.  
  19. ~/Desktop/pyco/test/app/user/models/user.py in upload_image_to(instance, filename)
  20.      23 def upload_image_to(instance, filename):
  21.      24     import pdb; pdb.set_trace()
  22. ---> 25     mime_type = imghdr.what(instance.primary_image)
  23.      26     # Normalize jpeg to jpg
  24.      27     if mime_type == 'jpeg':
  25.  
  26. /usr/lib/python3.6/imghdr.py in what(file, h)
  27.      17                 h = f.read(32)
  28.      18             else:
  29. ---> 19                 location = file.tell()
  30.      20                 h = file.read(32)
  31.      21                 file.seek(location)
  32.  
  33. ~/Desktop/pyco/test/env/lib/python3.6/site-packages/django/core/files/utils.py in <lambda>(self)
  34.      19     readlines = property(lambda self: self.file.readlines)
  35.      20     seek = property(lambda self: self.file.seek)
  36. ---> 21     tell = property(lambda self: self.file.tell)
  37.      22     truncate = property(lambda self: self.file.truncate)
  38.      23     write = property(lambda self: self.file.write)
  39.  
  40. ~/Desktop/pyco/test/env/lib/python3.6/site-packages/django/db/models/fields/files.py in _get_file(self)
  41.      39
  42.      40     def _get_file(self):
  43. ---> 41         self._require_file()
  44.      42         if not hasattr(self, '_file') or self._file is None:
  45.      43             self._file = self.storage.open(self.name, 'rb')
  46.  
  47. ~/Desktop/pyco/test/env/lib/python3.6/site-packages/django/db/models/fields/files.py in _require_file(self)
  48.      36     def _require_file(self):
  49.      37         if not self:
  50. ---> 38             raise ValueError("The '%s' attribute has no file associated with it." % self.field.name)
  51.      39
  52.      40     def _get_file(self):
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top