Read your settings.py file carefully: - you've said that the MEDIA_URL is / - but that Django is only configured to serve static content from /static
So when the photo is uploaded, it's stored in <MEDIA_ROOT>/photos/x.jpg, which you've told Django is accessible via the URL <site><MEDIA_URL>/photos. But this gives http://example.com/photos And, as per the error message, Django can't find a matching url pattern for that. Cheers, Malcolm On Sun, Feb 28, 2010 at 5:57 PM, lockwooddev <lockwood...@gmail.com> wrote: > Hi people, > > I started working on an image gallery with Django and I'm stuck. I > suppose that my static files on the development server are not > configured properly. > > I have the following models.py code: > > from django.db import models > from PIL import Image > > > class Photo(models.Model): > name = models.CharField(max_length=100) > description = models.TextField() > image = models.ImageField(upload_to='photos') > > > -------------------------------------------------------------------- > > My setting.py file: > > > MEDIA_ROOT = '/Users/lockwood/Django-1.1.1/md/static_media/' > MEDIA_URL = '/' > ADMIN_MEDIA_PREFIX = '/media/' > > > -------------------------------------------------------------------- > > And url.py file: > > urlpatterns = patterns('', > (r'^admin/', include(admin.site.urls)), > (r'^static/(?P<path>.*)$', 'django.views.static.serve', > {'document_root': settings.MEDIA_ROOT}), > ) > > > -------------------------------------------------------------------- > > When I click on the Photo object in the admin view to preview the > image i've uploaded, I get the following 404 page: > > > Page not found (404) > Request Method: GET > Request URL: > http://127.0.0.1:8000/photos/1459049280_144e7d874a_o-at-2008-12-06.jpg > > Using the URLconf defined in md.urls, Django tried these URL patterns, > in this order: > > 1. ^admin/ > 2. ^static/(?P<path>.*)$ > > The current URL, photos/1459049280_144e7d874a_o-at-2008-12-06.jpg, > didn't match any of these. > > -------------------------------------------------------------------- > > The photo's are stored in the absolute path: > > /Users/lockwood/Django-1.1.1/md/static_media/photos/ > > -------------------------------------------------------------------- > > I've tried everything and don't know what to do now? > > -- > 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. > > -- 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.