[Django]-Django File Upload with nginx / gunicorn – media permissions

6👍

First of all, media files folder has to be in you project’s path, otherwise you’ll be getting SuspiciousOpertion exception from Django, so don’t put it in /var/www.

Also, the fact that you are using nginx, is not that relevant, important part is which user is nginx/django project is running under, whichever user it is (normally www-data, at least with apache+mod_wsgi), that user should be the owner of the media folder.

Once you change the owner to the right user (I assume www-data): sudo chown -R www-data:www-data .../media, make sure permissions are correct: sudo chmod -R u+rwX .../media.

Hope it helped. Let me know if it didn’t. 🙂

👤lehins

2👍

Try upping the max_body_size in your nginx conf file:

server {
    ...

    client_max_body_size 250M;

    ...
}

By default it’s set to 1M which is possibly too small depending on what you’re uploading.

Leave a comment