这是我转到相关视图时遇到的完整错误。
/Library/Python/2.7/site-packages/django/core/files/base.py:106: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
if line[-1] in ('\n', '\r'):
代码非常简单。这是我的观点.py
def my_image(request):
clothes = Clothes.objects.get(clothesid = '2')
get_image = clothes.image
return HttpResponse(get_image, mimetype="image/png")
这是我的models.py
image = models.FileField(upload_to='images/')
完整的Clothes
模型如下所示:
class Clothes(models.Model):
clothesid = models.IntegerField(primary_key=True)
clothessize = models.CharField(max_length=255L, blank=True)
clothescolour = models.CharField(max_length=255L, blank=True)
clothestype = models.CharField(max_length=255L, blank=True)
image = models.FileField(upload_to='images/')
url = models.CharField(max_length=255L, blank=True)
gender = models.CharField(max_length=1L, blank=True)
clothescategory = models.CharField(max_length=255L, blank=True)
clothesage = models.CharField(max_length=255L, blank=True)
class Meta:
db_table = 'Clothes'
def __unicode__(self):
return self.image.name
在 MySQL 中,如果出现问题,则会整理图像字段latin1_swedish_ci
。
这里有什么问题?