0

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/;
}
mik.ro
  • 4,381
  • 2
  • 18
  • 23
  • See this will help you [http://stackoverflow.com/questions/20175243/django-gunicorn-not-load-static-files][1] [1]: http://stackoverflow.com/questions/20175243/django-gunicorn-not-load-static-files – Sanmugam Mar 25 '14 at 14:20
  • I think that my ngix is properly configured. It's rather a problem in django configuration – mik.ro Mar 25 '14 at 14:30

2 Answers2

1

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

mik.ro
  • 4,381
  • 2
  • 18
  • 23
0

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.

Alex
  • 8,321
  • 1
  • 34
  • 30
  • it doesn't help in this case – mik.ro Mar 25 '14 at 16:34
  • {% load static %} is up to version 1.3 – mik.ro Mar 25 '14 at 16:40
  • {% load static %} is still in 1.6 and serves a different purpose than {% load staticfiles %}. See [link](https://docs.djangoproject.com/en/1.6/ref/templates/builtins/#static) Basically, load static works for the STATIC_URL while load staticfiles works with the staticfiles contrib app. – Alex Mar 25 '14 at 16:48