Replace STATIC_URL_PREFIX by MEDIA_URL.
authorMatthijs Kooijman <matthijs@stdin.nl>
Fri, 31 Oct 2008 10:07:05 +0000 (11:07 +0100)
committerMatthijs Kooijman <matthijs@stdin.nl>
Fri, 31 Oct 2008 10:07:05 +0000 (11:07 +0100)
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).

settings.py
templates/base/base.html
urls.py

index e66d70964fa448c0c65622a71f461cf96e280c8b..30463db4fd2e346f5332d644a6519d32a7647c51 100644 (file)
@@ -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/"
index b64e4449ec5d35cbd12b6f48b8d139e041c2bb4c..9f0e7e2c579efa803f85daaa006b56da4cdf7aa4 100644 (file)
@@ -4,13 +4,13 @@
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
 {# <link rel="stylesheet" type="text/css" href="http://www.evolution-events.nl/algemeen/css.php?skin=lex"/> #}
-<link rel="stylesheet" type="text/css" href="{{ STATIC_URL_PREFIX }}/base/css/lex.css"/>
+<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}/base/css/lex.css"/>
 
-<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{{ STATIC_URL_PREFIX }}/base/css/base.css{% endblock %}"/>
+<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{{ MEDIA_URL }}/base/css/base.css{% endblock %}"/>
 {# <script type="text/javascript" src="http://yui.yahooapis.com/2.5.1/build/yahoo-dom-event/yahoo-dom-event.js"></script>  #}
 {# <script type="text/javascript" src="http://yui.yahooapis.com/2.5.1/build/logger/logger-debug.js"></script> #}
-<script type="text/javascript" src="{{ STATIC_URL_PREFIX }}/base/js/yahoo-dom-event.js"></script> 
-<script type="text/javascript" src="{{ STATIC_URL_PREFIX }}/base/js/logger-debug.js"></script> 
+<script type="text/javascript" src="{{ MEDIA_URL }}/base/js/yahoo-dom-event.js"></script> 
+<script type="text/javascript" src="{{ MEDIA_URL }}/base/js/logger-debug.js"></script> 
 <title>Xerxes</title>
 </head>
 <body>
diff --git a/urls.py b/urls.py
index 6265def1b10eaecf07718362f06c003a4992ef42..0ff28c102adc52fffa93e97d18b42922c03c291e 100644 (file)
--- a/urls.py
+++ b/urls.py
@@ -31,7 +31,7 @@ urlpatterns = patterns('',
 
 if settings.DEBUG:
     urlpatterns += patterns('',
-        (r'^static/(?P<path>.*)$', 'django.views.static.serve',
-        {'document_root': os.path.join(settings.PROJECT_DIR, 'static')}),
+        (r'^' + settings.MEDIA_URL[1:] + '(?P<path>.*)$', 'django.views.static.serve',
+        {'document_root': settings.MEDIA_ROOT}),
     )
 # vim: set sts=4 sw=4 expandtab: