From: Matthijs Kooijman Date: Fri, 31 Oct 2008 10:07:05 +0000 (+0100) Subject: Replace STATIC_URL_PREFIX by MEDIA_URL. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=58fea93b179a34faacdd636c6532016f1c395d36;p=matthijs%2Fprojects%2Fxerxes.git Replace STATIC_URL_PREFIX by MEDIA_URL. STATIC_URL_PREFIX was a custom creation, but it is now clear that MEDIA_URL is meant for exactly the same thing (and not just for uploaded files, as I previously thought). --- diff --git a/settings.py b/settings.py index e66d709..30463db 100644 --- a/settings.py +++ b/settings.py @@ -44,20 +44,16 @@ USE_I18N = True # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" -MEDIA_ROOT = '' +MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media') # URL that handles the media served from MEDIA_ROOT. # Example: "http://media.lawrence.com" -MEDIA_URL = '' - -# URL prefix for static files. Will be made available by -# xerxes.tools.context_processors.static -STATIC_URL_PREFIX = '/static/' +MEDIA_URL = '/media/' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/", "/media/". -ADMIN_MEDIA_PREFIX = '/media/' +ADMIN_MEDIA_PREFIX = '/admin/media/' # Make this unique, and don't share it with anybody. SECRET_KEY = '6-zo+-1@-342%k4%82aw#kxr4f%5w00xhwby5$&fa@+!dh@(2=' @@ -104,8 +100,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", - # Add STATIC_URL_PREFIX to the context - "xerxes.tools.context_processors.static", + "django.core.context_processors.media", ) LOGIN_URL = "/accounts/login/" diff --git a/templates/base/base.html b/templates/base/base.html index b64e444..9f0e7e2 100644 --- a/templates/base/base.html +++ b/templates/base/base.html @@ -4,13 +4,13 @@ {# #} - + - + {# #} {# #} - - + + Xerxes diff --git a/urls.py b/urls.py index 6265def..0ff28c1 100644 --- a/urls.py +++ b/urls.py @@ -31,7 +31,7 @@ urlpatterns = patterns('', if settings.DEBUG: urlpatterns += patterns('', - (r'^static/(?P.*)$', 'django.views.static.serve', - {'document_root': os.path.join(settings.PROJECT_DIR, 'static')}), + (r'^' + settings.MEDIA_URL[1:] + '(?P.*)$', 'django.views.static.serve', + {'document_root': settings.MEDIA_ROOT}), ) # vim: set sts=4 sw=4 expandtab: