dimanche 30 avril 2017

Django admin static files

I want to deploy a server using nginx, django & gunicorn. I created a django project in /home/myproj/ with STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static'), did all the migrations, and then python3 manage.py collectstatic

then I changed the nginx configuration:

server {
    listen 80;
    server_name www.myserver.com;
    access_log  /home/nginx.log;

    location /static/ {
        alias /home/myproj/static/;
        autoindex on;
        expires 30d;
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

when I start the server gunicorn myproj.wsgi:application the start page is displayed correctly, but the admin panel does not load the css styles. What am I doing wrong?

P.S. I'm still not good in linux, so please write the full commands.




Aucun commentaire:

Enregistrer un commentaire