mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Add SpecFile.__unicode__
SpecFile is based after django.core.files.base.ContentFile, which lacks a __unicode__ method. This leads to an AttributeError when SpecFile.__repr__ is called. This is easily resolved by giving SpecFile a proper __unicode__ method.
This commit is contained in:
parent
1c8987e353
commit
db4df4f82c
1 changed files with 5 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import os
|
|||
from StringIO import StringIO
|
||||
|
||||
from django.core.files.base import ContentFile
|
||||
from django.utils.encoding import smart_str, smart_unicode
|
||||
|
||||
from .processors import ProcessorPipeline, AutoConvert
|
||||
from .utils import img_to_fobj, open_image, \
|
||||
|
|
@ -25,7 +26,10 @@ class SpecFile(ContentFile):
|
|||
self.file.content_type = None
|
||||
|
||||
def __str__(self):
|
||||
return self.file.name
|
||||
return smart_str(self.file.name or '')
|
||||
|
||||
def __unicode__(self):
|
||||
return smart_unicode(self.file.name or u'')
|
||||
|
||||
|
||||
class SpecFileGenerator(object):
|
||||
|
|
|
|||
Loading…
Reference in a new issue