The file permissions are right AFAIK; the directory is mode 755 and the file
644, owned by the user running the server, so accessing and reading
shouldn't be a problem.

Are you using Django installed through the package manager or the latest
release from djangoproject.com?

On Tue, Apr 27, 2010 at 6:37 PM, Xavier Ordoquy <xordo...@linovia.com>wrote:

> It is pretty much what I also have and works both on ubuntu 9.10 32 bits
> and osx.
>
> Did you checked that your media directory exists and lives in the same
> directory as the settings.py ?
> Also check that you have the right permissions for accessing it with the
> user that runs the dev server.
>
> Regards,
> Xavier.
>
> Le 28 avr. 2010 à 01:00, Jonathan Hayward a écrit :
>
> Thank you!
>
> Right now, I have, in settings.py:
>
> MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)),
> 'media')
>
> MEDIA_URL = '/media/'
>
> And at the end of urls.py:
>
> 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 }),)
>
> But I'm still getting a "not found" error when I try to load a picture from
> the media directory. I am also getting "Permission denied: /media/" when I
> load the root media URL.
>
> I'm on an Ubuntu32 9.10 system, so even if I should be specifying a virgule
> instead of os.path.join(), the path should be forward slash separated. Is
> there anything that looks askew about the code above?
>
> On Tue, Apr 27, 2010 at 5:28 PM, Xavier Ordoquy <xordo...@linovia.com>wrote:
>
>> 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<django-users%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> → 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
→ 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.

Reply via email to