Update picture upload
This commit is contained in:
parent
bdc6d36ce4
commit
a93859167a
@ -10,7 +10,7 @@ from django.contrib.auth.models import User
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.encoding import smart_str
|
||||
from enum import Enum
|
||||
|
||||
MAX_LENGTH = 256
|
||||
@ -114,7 +114,7 @@ class UserFoodImage(models.Model):
|
||||
suf = SimpleUploadedFile(os.path.split(self.image.name)[-1],
|
||||
temp_handle.read(),
|
||||
content_type='image/jpg')
|
||||
str_food = smart_text(self.food.name, encoding='utf-8')
|
||||
str_food = smart_str(self.food.name, encoding='utf-8')
|
||||
self.thumb.save('%s_%s_thumbnail.%s' % (str_food, self.user.username, 'jpg'), suf, save=False)
|
||||
# save the image object
|
||||
self.image.name = "%s_%s_original.%s" % (str_food, self.user.username, 'jpg')
|
||||
|
||||
Reference in New Issue
Block a user