Nikul Panchal
Nikul Panchal

Reputation: 1673

static file are not working in django nginx

I have created one small app, and uploaded to the aws server, i can see everything is working except static folder, my static folder is under the /home/ubuntu/django-bhuriyo/mysite/ this directory, i am using nginx, i have put my code of nginx conf and settings.py, can anyone please look my code and help me to resolve this issue ?

django.conf

server {
        listen 80;
        server_name ****.amazonaws.com;

        location /static {
                alias /home/ubuntu/django-bhuriyo/mysite;
        }

        location /  {
                include proxy_params;
                proxy_pass http://unix:/home/ubuntu/django-bhuriyo/app.sock;
        }

}

settings.py

STATIC_URL  = 'static'
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)

STATIC_ROOT = '/home/ubuntu/django-bhuriyo/mysite'

Upvotes: 0

Views: 124

Answers (2)

Joseba S.
Joseba S.

Reputation: 181

I see everything fine... are you collecting the files?

python manage.py collectstatic

You need that command for Django to copy over all your static files to the directory specified in the STATIC_ROOT setting. Remember you have to execute that every time you have some change in your static files.

Upvotes: 1

oz grow
oz grow

Reputation: 55

You also have to declare the path of the media.

MEDIA_URL = '/media/'

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

and location for nginx :

  location = /media/ {
        root /path/to/medias;
    }

what is your error traceback ?

Upvotes: 0

Related Questions