Static files not being served on Django
<p>I am trying to serve static files in Django in development (<code>DEBUG=True</code>) mode. I have a directory structure like this:</p>

<pre><code>my_project/
  ...
  static/
    img.png
</code></pre>

<p>In my <code>settings.py</code> I have this:</p>

<pre><code>STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATICFILE_DIRS = [
    os.path.join(BASE_DIR, "static"),
]
STATIC_URL = '/static/'
STATICFILES_FINDERS = ( 
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
</code></pre>

<p>and in <code>my_project/urls.py</code> I have this:</p>

<pre><code>from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin

urlpatterns = [
    # ...
    url(r'^admin/', include(admin.site.urls)),
    url(r'^', include('app.landing.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
</code></pre>

<p>This all seems to be correct. When I visit <a href="http://127.0.0.1:8000/static/img.png" rel="nofollow">http://127.0.0.1:8000/static/img.png</a> though, I get a 404.</p>

<p>What am I doing wrong?</p>

<p>You can debug this in many different ways. Here's my approach.</p>

<p>main settings.py:</p>

<pre><code>DEBUG = False
TDEBUG = True
</code></pre>

<p>urls.py:</p>

<pre><code>from django.conf import settings
import os

if settings.TDEBUG:
    urlpatterns += patterns('',
        (r'^static/(?P&lt;path&gt;.*)$', 'django.views.static.serve',
         {'document_root': os.path.join(os.path.dirname(__file__), 'static')} ),
    )
</code></pre>

python django