I am using django-imagekit to create thumbnails of my image field.
class CustomUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(_('email address'), max_length=254, unique=True)
image = ProcessedImageField(upload_to= generate_random_filename,
processors=[ResizeToFill(640, 640)],
format='JPEG',
options={'quality': 60})
avatar = ImageSpecField(source='image',
processors=[ResizeToFill(96, 96)],
format='JPEG',
options={'quality': 60})
Now I created a serializer for the above model using django-rest-framework:
class UserRegistrationSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = tuple(User.REQUIRED_FIELDS) + (
User.USERNAME_FIELD,
User._meta.pk.name,
'image',
'avatar',
)
I have created a generics.CreateAPIView to save a new user but, it gives error:
UnicodeDecodeError at /register/
'ascii' codec can't decode byte 0xff in position 11: ordinal not in range(128)
Unicode error hint
The string that could not be encoded/decoded was: "����\u
I don't understand this. Please help. It works fine if I remove avatar from the serializer.