mik.ro
mik.ro

Reputation: 4893

staticfiles loaded the wrong path - app_name/static/

it's my very beginning with the django. I've configured server with nginx and gunicorn. The problem is that static files are not being loaded correctly. When I go to the source code I can see, f.e:

<link href="/app_name/static/css/bootstrap.min.css" rel="stylesheet">  

although the correct file is located under: /static/css/bootstrap.min.css

So it seems that "app_name" is added before path to my /static/ folder.

settings.py file:

STATIC_ROOT = '/webapps/filmyposlowie/static/'
STATIC_URL =  '/static/'

index.html file:

   {% load staticfiles %}

    <link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet">

nginx:

location /static/ {
    alias   /webapps/filmyposlowie/static/;
}

Upvotes: 0

Views: 909

Answers (2)

mik.ro
mik.ro

Reputation: 4893

Restarting the server after changing setting.py file has helped me. In my case it was: supervisorctl restart [process_name]

Upvotes: 1

Alex
Alex

Reputation: 8539

Do you have a STATICFILES_STORAGE setting in settings.py?

If not, try changing {% load staticfiles %} to {% load static %} in your index.html file. I had a similar problem once.

Upvotes: 0

Related Questions