diff --git a/example/cheeseshop/settings.py b/example/cheeseshop/settings.py index ddb829c..b13adcf 100644 --- a/example/cheeseshop/settings.py +++ b/example/cheeseshop/settings.py @@ -55,6 +55,8 @@ MEDIA_ROOT = '' # Examples: "http://media.lawrence.com", "http://example.com/media/" MEDIA_URL = '' +STATIC_URL = '/static/' + # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/", "/media/". diff --git a/example/cheeseshop/urls.py b/example/cheeseshop/urls.py index a93124a..e3cb696 100644 --- a/example/cheeseshop/urls.py +++ b/example/cheeseshop/urls.py @@ -1,4 +1,6 @@ from django.conf.urls.defaults import * +from django.contrib.staticfiles.urls import staticfiles_urlpatterns +from django.conf import settings # Uncomment the next two lines to enable the admin: from django.contrib import admin @@ -8,10 +10,20 @@ urlpatterns = patterns('', # Example: # (r'^cheeseshop/', include('cheeseshop.foo.urls')), - # Uncomment the admin/doc line below and add 'django.contrib.admindocs' + # Uncomment the admin/doc line below and add 'django.contrib.admindocs' # to INSTALLED_APPS to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^admin/', include(admin.site.urls)), ) + +if settings.DEBUG: + urlpatterns += staticfiles_urlpatterns() + urlpatterns += patterns( + '', + url(r'^media/(?P.*)$', + 'django.views.static.serve', { + 'document_root': settings.MEDIA_ROOT, + }), + )