Reputation: 197
Using django 1.7 and python3.2 I've been working on a model. The picture field keep sending me a 400 Error when i'm trying to upload a JPG picture but works perfectly well when using a PNG. It is just randomly accepting some pictures
I've removed to 'upload_to' parameter since I tough it was what caused the error. Apparently not. Is it worth creating an issue or am I missing something ?
UPDATE : PNG files can create the error as well. Converted the picture with photoshop and I still got the error. After a while I tried to reproduce the error to get a traceback and it worked perfectly fine... I'll post the exact error I got as soon as it happens again
class Release(models.Model):
title = models.CharField(max_length=300)
label = models.ForeignKey('Label')
author = models.ForeignKey('Artist')
picture = models.FileField(blank=True, null=True)
public = models.BooleanField(default=False)
def __str__(self):
return self.title
My terminal prints :
[04/Dec/2014 09:46:20] code 400, message Bad request syntax ('\x0b\x97\x98tÚd\x7fÒ\x9a8ê\x99G\\åb\x8f776_¾z5\x9b\x7f¾à¶¶u>}ö⯿9ÀÀ)7_ÿÇß\x9fø*±ã\x7füí7\x8d\x9a\x9eÒWÉ"I7å=\x06²5Ôû«÷\r«\x95i©\x9aðw²ÐDºfªC\x87P¬7R\x891\x9d%¢\x11)}dQ\x02×æå\x01Ôññ»££ã²\x888ÿàëWÉú¹2P\x04¿«-a\x10HÀ{ëPðÕ{)Ãl+þþjÏ71ç¦ø¯\x87;\x9bd3á\rªý\x03k\x07Ûô\x8cgÏ÷ÿïÿùï¯÷önÚÅsÃZ8\x95®´¦æ\x9fþZ×\x80.Ä\x838\x84ìJ\'Ap\x8a$b:ãòê4ÕÉ\x1e\x90\x03\x83¼1mC; \x86ÚÐ^¾÷\x99')
[04/Dec/2014 09:46:20] "ªýkÛôgÏ÷ÿïÿùï¯÷önÚÅsÃZ8®´¦æþZ×.Ä8ìJ'Ap$b:ãòê4Õɼ1mC; ÚÐ^¾÷" 400 -;
And I either receive a "not available page" or the same error. No traceback and no log in my logging file.
My settings.py:
FILE_UPLOAD_PERMISSIONS = 0o644
MEDIA_ROOT = 'upload/'
MEDIA_URL = ''
I also changed my model to have :
picture = models.ImageField(blank=True, null=True)
But this doesn't help at all...
WEIRD UPDATE :
Cannot reproduce the bug in front of a Friend. Now wonder what gonna do with that bounty, Mysteries of Django EP 1 in 3 year of web dev in Django.
WEIRD UPDATE 2 :
Removed my BDD and re-synced : problem appeared again...
Info edito : IT'S ALL IN THE DJANGO ADMIN, NO CUSTOM HTML, NO CUSTOM CODE EXCEPT THE ONE I POSTED HERE
Screenshot of the error... https://i.sstatic.net/oAcL1.jpg
Upvotes: 0
Views: 400
Reputation: 3955
Change
def __str__(self):
return self.title
to
def __unicode__(self):
return self.title
Upvotes: 0
Reputation: 11
Mabye the failing images have filenames that contain non-ascii characters?
Change __str__
to __unicode__
(edited for markdown)
Upvotes: 1