Renato Prado
Renato Prado

Reputation: 4150

Django not collecting static files

Im trying to collect static files on django production hosting website: jumentosemuaresonline.com.br

My configuration:

DEBUG = False
ALLOWED_HOSTS = [".jumentosemuaresonline.com.br"]
STATIC_ROOT = os.path.join(BASE_DIR,'static/')
STATIC_URL = os.path.join(BASE_DIR,'/static/')

When i print static root on setting, returns the exact path of the ftp

/home/jumentosemuaresonline/apps_wsgi/website/static/

when i execute python manage.py collectstatic -v 0 It also return the exact path of the ftp

/home/jumentosemuaresonline/apps_wsgi/website/static/

But when i execute python mange.py collectstatic it dont fill the static folder with the static files, only returns

0 static files copied, 109 unmodified.

Anyone have idea what am i missing?

I figured out what was happening: The collect static command was working fine but I was using Nginx in front of the application as a reverse proxy, Nginx has to serve the static path not django.

upstream django_app {
    server djangohost:8000;
}

server {

    listen 80;

    location / {
        proxy_pass http://django_app;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
    }

    location /static/ {
        alias /my/static_path/;
    }

}

Upvotes: 2

Views: 3276

Answers (1)

arjoonn
arjoonn

Reputation: 988

It says 109 unmodified. The files are already there.
Try ls /home/jumentosemuaresonline/apps_wsgi/website/static/
That should show you all the files there.

Just in case. Try this too. rm -rf /home/jumentosemuaresonline/apps_wsgi/website/static/ mkdir /home/jumentosemuaresonline/apps_wsgi/website/static/ python manage.py collectstatic

This should show you 109 copied and 0 modified.

Upvotes: 3

Related Questions