Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File upload - Bad request (400)

Tags:

python

django

When I try to upload file via FileField of my model using Django administration I get following response from Django development server:

<h1>Bad Request (400)</h1>

The only output in console is:

[21/Jul/2013 17:55:23] "POST /admin/core/post/add/ HTTP/1.1" 400 26

I have tried to find an error log, but after reading few answers here I think there is nothing like that because Django usually prints debug info directly to browser window when Debug=True (my case).

How can I debug this problem further?

like image 849
Petr Peller Avatar asked Jul 21 '13 16:07

Petr Peller


1 Answers

In my case it was a leading '/' character in models.py.

Changed /products/ to products/ in:

product_image = models.ImageField(upload_to='products/')

like image 136
Krishan Gupta Avatar answered Oct 06 '22 14:10

Krishan Gupta