This is the complete error that I am getting when I go to the relevant view.
/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'):
The code is pretty straightforward. This is in my views.py
def my_image(request):
clothes = Clothes.objects.get(clothesid = '2')
get_image = clothes.image
return HttpResponse(get_image, mimetype="image/png")
And this is in my models.py
image = models.FileField(upload_to='images/')
The complete Clothes
model looks like this:
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
In MySQL, the image field is collated as latin1_swedish_ci
in case that is an issue.
What is the problem here?