Extract a file like object's file name as per docs (using the .name property) and not an unicode representation of the file object instance. Reference: https://docs.python.org/2.7/library/stdtypes.html#file-objects
This commit is contained in:
@@ -127,7 +127,7 @@ class DocumentType(models.Model):
|
||||
with transaction.atomic():
|
||||
document = self.documents.create(
|
||||
description=description or '',
|
||||
label=label or unicode(file_object),
|
||||
label=label or file_object.name,
|
||||
language=language or setting_language.value
|
||||
)
|
||||
document.save(_user=_user)
|
||||
@@ -138,7 +138,7 @@ class DocumentType(models.Model):
|
||||
logger.critical(
|
||||
'Unexpected exception while trying to create new document '
|
||||
'"%s" from document type "%s"; %s',
|
||||
label or unicode(file_object), self, exception
|
||||
label or file_object.name, self, exception
|
||||
)
|
||||
raise
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class Source(models.Model):
|
||||
with transaction.atomic():
|
||||
document = Document.objects.create(
|
||||
description=description or '', document_type=document_type,
|
||||
label=label or unicode(file_object),
|
||||
label=label or file_object.name,
|
||||
language=language or setting_language.value
|
||||
)
|
||||
document.save(_user=user)
|
||||
@@ -100,7 +100,7 @@ class Source(models.Model):
|
||||
logger.critical(
|
||||
'Unexpected exception while trying to create new document '
|
||||
'"%s" from source "%s"; %s',
|
||||
label or unicode(file_object), self, exception
|
||||
label or file_object.name, self, exception
|
||||
)
|
||||
raise
|
||||
|
||||
|
||||
Reference in New Issue
Block a user