Question

Upload media files django nginx

Posted August 23, 2018 2.6k views
DjangoDeploymentUbuntu 18.04

I’m trying to upload media files on the server but can’t figure out how to do it.
I have no problem accessing my media files, but can’t upload any.

Here is what I’ve tried:

server {
    listen 80;
    server_name ****;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/joseph/hacka;
    }
    location /media/ {
        root /home/joseph/hacka;
    }
    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

In my settings.py, I have :

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

Please help me if you know the answer to my problem.

1 comment
Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!