You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
497 B
14 lines
497 B
from django.forms import ImageField as BaseImageField
|
|
|
|
|
|
class ImageField(BaseImageField):
|
|
|
|
def to_internal_value(self, data):
|
|
# if data is None image field was not uploaded
|
|
if data:
|
|
file_object = super(ImageField, self).to_internal_value(data)
|
|
django_field = self._DjangoImageField()
|
|
django_field.error_messages = self.error_messages
|
|
django_field.to_python(file_object)
|
|
return file_object
|
|
return data
|
|
|