Hi,

Here's something better for your dev server:

from django.conf import settings

if settings.DEBUG:
    urlpatterns += patterns('django.views.static',
    (r'^%s(?P<path>.*)$' % (settings.MEDIA_URL[1:],),  'serve', {
                                                'document_root': 
settings.MEDIA_ROOT,
                                                'show_indexes': True }),)


To answer your question, you should use 
os.path.abspath(os.path.dirname(__file__)) instead of os.path.dirname(__file__).

Regards,
Xavier.


Le 28 avr. 2010 à 00:00, Jonathan Hayward a écrit :

> I'm trying to serve up media from a document_root of <project name>/media 
> via, in urls.py:
> 
> urlpatterns = patterns('',
> ...
>     (r'^media/(?P<path>.*)$', 'django.views.static.serve',
>       {'document_root': os.path.join(os.path.dirname(__file__), 'media')}),
> ...
> 
> It gives a "file not found" error, either this way or if I add a trailing 
> slash.
> 
> How can I serve up static content from <project name>/media/* to a URL of 
> /media/* from the development server?
> 
> -- 
> → Jonathan Hayward, christos.jonathan.hayw...@gmail.com
> → An Orthodox Christian author: theology, literature, et cetera.
> → My award-winning collection is available for free reading online:
> ☩ I invite you to visit my main site at http://JonathansCorner.com/
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to