pythondjangostaticserving

Django 1.7 - Serving static files


I'm following the official documentation in order to serve static files but I'm recieving error 404 in the development console. I'm using 'django.contrib.staticfiles', so static files should be automatically served. This is my setup:

Settings:

STATIC_ROOT = ''
STATIC_URL = '/static/'

Template header:

{% load staticfiles %}
<link rel="stylesheet" href="{% static "css/app.css" %}">

Directory tree:

django_project
    \apps
    \static
        \css
            app.css
    \templates
        index.html

I can see in firefox console that the path to my file is correct:

enter image description here

So the problem must be that Django is not serving static files. I can't find what I'm missing. Any advice is more than welcome.


Solution

  • SOLUTION: I was missing this line in my settings.py

    STATICFILES_DIRS = (os.path.join(os.path.dirname(__file__),'static'),)
    

    It looks it's mandatory, same as TEMPLATE_DIRS.