skip to Main Content

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 ('x0bx97x98tÚdx7fÒx9a8êx99G\åbx8f776_¾z5x9bx7f¾à¶¶u>}ö⯿9ÀÀ)7_ÿÇßx9fø*±ãx7füí7x8dx9ax9eÒWÉ"I7å=x06²5Ôû«÷r«x95i©x9aðw²ÐDºfªCx87P¬7Rx891x9d%¢x11)}dQx02×æåx01Ôññ»££ã²x888ÿàëWÉú¹2Px04¿«-ax10HÀ{ëPðÕ{)Ãl+þþjÏ71ç¦ø¯x87;x9bd3árªýx03kx07Ûôx8cgÏ÷ÿïÿùï¯÷önÚÅsÃZ8x95®´¦æx9fþZ×x80.Äx838x84ìJ'Apx8a$b:ãòê4ÕÉx1ex90x03x83¼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… http://imgur.com/Ehq2v5D

2

Answers


  1. Mabye the failing images have filenames that contain non-ascii characters?

    Change __str__ to __unicode__ (edited for markdown)

    Login or Signup to reply.
  2. Change

    def __str__(self):
            return self.title
    

    to

    def __unicode__(self):
            return self.title
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search