1
Use python_2_unicode_compatible decorator:
from django.utils.encoding import python_2_unicode_compatible, force_text
@python_2_unicode_compatible
class Property (models.Model):
#...
city = models.CharField(max_length = 100, choices = CITIES_LIST)
pdf_file = models.FileField(upload_to = generateUploadPath)
def __str__(self):
return force_text(self.pdf_file.path)
def __unicode__(self):
return force_text(unicode(self.pdf_file.path))
def get_file_path(self):
return force_text(unicode(self.pdf_file.path))
Source:stackexchange.com