No static files using Gunicorn

When I am running runserver everything is ok with static files, but when I an running gunicorn there is no static files. Please, help.

STATIC_URL = ‘/static/’
STATICFILES_DIRS = [
os.path.join(BASE_DIR, ‘webstudio’, ‘templates’),
]

MEDIA_URL = ‘/media/’
MEDIA_ROOT = os.path.join(BASE_DIR, ‘webstudio’, ‘media’)

server {
listen 80;
server_name www.webstudioamerica.com;

return 301 $scheme://webstudioamerica.com$request_uri;

}

server {
server_name webstudioamerica.com;

location = /favicon.ico { access_log off; log_not_found off; }

location /templates/ {
    root /home/Oriander/webstudioamerica/webstudio/;
}

location / {
    include proxy_params;
    proxy_pass http://127.0.0.1:8000;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/webstudioamerica.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/webstudioamerica.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
if ($host = www.webstudioamerica.com) {
return 301 https://webstudioamerica.com$request_uri;
} # managed by Certbot

if ($host = webstudioamerica.com) {
    return 301 https://$host$request_uri;
} # managed by Certbot

listen 80;
server_name webstudioamerica.com www.webstudioamerica.com;
return 404; # managed by Certbot

}

Start by reading the docs at How to deploy static files | Django documentation | Django

  • You have no definition in your nginx configuration to serve the static files.

  • You don’t show a definition for STATIC_ROOT

  • Your MEDIA_ROOT points to a directory within your project directory.

1 Like