Trying to serve django static files on development server - not found
Question: I've followed the instructions in [this
question](http://stackoverflow.com/q/9197599/344286), [the
documentation](https://docs.djangoproject.com/en/dev/howto/static-files/), and
I've even looked at [this one](http://stackoverflow.com/q/10644649/344286),
but so far I'm unable to get at my static files using `python manage.py
runserver`.

These are my (relevant?) settings:

    
    
    STATIC_ROOT '/home/wayne/programming/somesite/static'
    STATICFILES_DIRS ('/home/wayne/programming/somesite/static/styles',
                      '/home/wayne/programming/somesite/static/admin')
    

In my urls.py:

    
    
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns
    # The rest of my urls here...
    if settings.DEBUG:
        urlpatterns += staticfiles_urlpatterns()
    

I have the following code in my base.html

    
    
        <link rel="stylesheet" type="text/css" href="{% static "styles/main.css" %}">
        {% block styles %}
        {% for sheet in styles %}
        <link rel="stylesheet" type="text/css" href="{% static sheet %}">
        {% endfor %}
    

And I promise I'm not hallucinating:

    
    
    (.env)wayne:~/programming/somesite/static$ pwd 
    /home/wayne/programming/somesite/static 
    (.env)wayne:~/programming/somesite/static$ ls 
    admin  styles 
    

However, when navigate to `http://localhost:8000/` my site is missing its
stylesheets, and when I go to `http://localhost:8000/static/styles/main.css` I
get `'styles/main.css' could not be found`, and trying to navigate to
`localhost:8000/static/`, or `localhost:8000/static/styles` it tells me that
Directory indexes are not allowed.

What am I missing here?


Answer: Django's handling of static files continue to be slightly confusing,
particularly in terms of the naming of relevant settings.

The short answer is to move your static files; instead of

    
    
    /home/wayne/programming/somesite/static
    

put them in

    
    
    /home/wayne/programming/somesite/yourapp/static
    

(where "yourapp" is obviously the name of your main application).

The longer answer is that I think you've (understandably) become confused
about the various settings. `STATIC_ROOT` _only_ refers to the location
**where your static files should end up** after running `manage.py
collectstatic`. You don't need this set (as you shouldn't really need
`collectstatic`) when developing locally. Either way, `STATIC_ROOT` should
always refer to an empty directory.

Your `STATICFILES_DIRS` setting would almost work, except that you've told
Django there are two paths where it should find static files

    
    
    /home/wayne/programming/somesite/static/styles
    /home/wayne/programming/somesite/static/admin
    

so when you do `{% static "styles/main.css" %}` it will look for

    
    
    /home/wayne/programming/somesite/static/styles/styles/main.css
    /home/wayne/programming/somesite/static/admin/styles/main.css
    

and will obviously not find them. What _might_ work is

    
    
    STATICFILES_DIRS = ('/home/wayne/programming/somesite/static',)
    

but there's no need to do that, as you can just rely on
`django.contrib.staticfiles.finders.AppDirectoriesFinder` (in [the default
STATICFILES_FINDERS](https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/#std%3asetting-
STATICFILES_FINDERS)) and move your static files to an app directory.

Hope this clears things up a little.

