error in implementing static files in django

Posted by POOJA GUPTA on Stack Overflow See other posts from Stack Overflow or by POOJA GUPTA
Published on 2012-07-10T09:13:54Z Indexed on 2012/07/10 9:15 UTC
Read the original article Hit count: 451

my settings.py file:-

STATIC_ROOT = '/home/pooja/Desktop/static/'

# URL prefix for static files.
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
                 '/home/pooja/Desktop/mysite/search/static',
          )

my urls.py file:-

from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^search/$','search.views.front_page'),
    url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += staticfiles_urlpatterns()

I have created an app using django which seraches the keywords in 10 xml documents and then return their frequency count displayed as graphical representation and list of filenames and their respective counts.Now the list has filenames hyperlinked, I want to display them on the django server when user clicks them , for that I have used static files provision in django. Hyperlinking has been done in this manner:

<ul> 
   {% for l in list1 %}
          <li><a href="{{STATIC_URL}}static/{{l.file_name}}">{{l.file_name}}</a{{l.frequency_count</li>
   {% endfor %}
</ul>

Now when I run my app on the server, everything is running fine but as soon as I click on the filename, it gives me this error :

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^search/$
^admin/
^static\/(?P<path>.*)$
The current URL, search/static/books.xml, didn't match any of these.

I don't know why this error is coming, because I have followed the steps required to achieve this. I have posted my urls.py file and it is showing error in that only.

I'm new to django , so

Please help

© Stack Overflow or respective owner

Related posts about python

Related posts about linux