user3415175
user3415175

Reputation: 101

upload to attribute in django with FileField

I face a problem with FileField I can't upload any files in admin page, every time I tried to upload I got this message Bad Request (400)

while the code is as below:

IDAttached = models.FileField(upload_to='/documents/%Y/%m/',null=True, blank= True)

Thank you for support,

Upvotes: 1

Views: 712

Answers (1)

ferrangb
ferrangb

Reputation: 2050

Try without the first slash:

IDAttached = models.FileField(upload_to='documents/%Y/%m/',null=True, blank= True)

If it still doesn't work, make sure you have MEDIA_ROOT in setting.py properly configured.

Upvotes: 1

Related Questions