title: Django: static files
body: <p>When i try to serve up images from within my blog the template is looking in </p>
  
  <pre><code>[26/Mar/2012 10:33:42] "GET /blog/images/coke.jpg HTTP/1.1" 200 6153
  </code></pre>
  
  <p>However when i load up images from a flat page the template looks in</p>
  
  <p>[26/Mar/2012 10:33:42] "GET /blog/images/coke.jpg HTTP/1.1" 200 6153</p>
  
  <p>I think this is because i need to add something to my urls.py file with my blog app so that it knows what my static URL is rather than looking in the blog/images folder.</p>
  
  <p>Im using the tag:</p>
  
  <pre><code>src="{{ STATIC_URL }}images/header.png"
  </code></pre>
  
  <p>My settings.py has:</p>
  
  <pre><code>STATIC_ROOT = '/export/mailgrp4_a/sc10jbr/WWWdev/dbe/djangostatic/'
  STATIC_URL = '/static/'
  STATICFILES_DIRS = (
  '/export/mailgrp4_a/sc10jbr/WWWdev/dbe/static/',
  </code></pre>
  
  <p>My blog url.py has:</p>
  
  <pre><code>urlpatterns = patterns('dbe.blog.views',
  (r"^(\d+)/$", "post"),
  (r"^add_comment/(\d+)/$", "add_comment"),
  (r"^delete_comment/(\d+)/$", "delete_comment"),
  (r"^delete_comment/(\d+)/(\d+)/$", "delete_comment"),
  (r"^month/(\d+)/(\d+)/$", "month"),
  (r"", "main"),
  )
  </code></pre>
  
  <p>My main url.py has:</p>
  
  <pre><code>urlpatterns = patterns('',
  url(r'^blog/', include('blog.urls')),
  url(r'^admin/', include(admin.site.urls)),
  )
  </code></pre>
  
  <p>What do i need to add?</p>
  
  <p>My updated blog url.py has:</p>
  
  <pre><code>from django.conf.urls.defaults import *
  from dbe.blog.models import *
  from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  
  
  urlpatterns = patterns('dbe.blog.views',
  (r"^(\d+)/$", "post"),
  (r"^add_comment/(\d+)/$", "add_comment"),
  (r"^delete_comment/(\d+)/$", "delete_comment"),
  (r"^delete_comment/(\d+)/(\d+)/$", "delete_comment"),
  (r"^month/(\d+)/(\d+)/$", "month"),
  (r"", "main"),
  )
  
  urlpatterns += staticfiles_urlpatterns()
  </code></pre>
  
  <p>My updated main url.py has:</p>
  
  <pre><code>from django.conf.urls.defaults import *
  from dbe.blog.models import *
  from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  
  # Uncomment the next two lines to enable the admin:
  from django.contrib import admin
  admin.autodiscover()
  
  urlpatterns = patterns('',
  url(r'^blog/', include('blog.urls')),
  
  # Uncomment the admin/doc line below to enable admin documentation:
  url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
  
  # Uncomment the next line to enable the admin:
  url(r'^admin/', include(admin.site.urls)),
  
  )
  
  urlpatterns += staticfiles_urlpatterns()
  </code></pre>
  
  <p>Can anyone else help with this, im really stuck even after following the help below. Is there anything i can use to help debug and diagnose the problem?</p>
  
  <p>thanks</p>