Permalink
Browse files

switch to using DEBUG from SERVE_MEDIA

  • Loading branch information...
1 parent 04c078c commit a6c15cbf9fc6750f6ca93d895fcf0841d7fe9631 @lukeman lukeman committed Mar 8, 2012
View
@@ -75,10 +75,9 @@ You can learn much more about ``runfcgi`` from the Django documentation on
Media files
===========
-During development media files were handled for you. Running a production
-Pinax project it is **strongly** recommeneded you do not rely on
-``SERVE_MEDIA = True``. By default, ``SERVE_MEDIA`` is set to ``DEBUG`` which
-likely means moving to production will turn off ``SERVE_MEDIA``.
+During development media files are handled for you by staticfiles. Serving of
+media is controlled by ``DEBUG`` (previous versions of Pinax used an additional
+setting ``SERVE_MEDIA`` that controlled this behavior, but it is now unused).
Pinax, by default, sets ``STATIC_ROOT`` and ``MEDIA_ROOT`` to directories
within the same directory (``site_media``). This is very beneficial to running
@@ -9,9 +9,6 @@
DEBUG = True
TEMPLATE_DEBUG = DEBUG
-# tells Pinax to serve media through the staticfiles app.
-SERVE_MEDIA = DEBUG
-
# django-compressor is turned off by default due to deployment overhead for
# most users. See <URL> for more information
COMPRESS = False
@@ -7,7 +7,7 @@ The convention for this directory is:
* js/ — stores Javascript files
* img/ — stores image files
-This directory is accessed at /site_media/static/ in runserver when SERVE_MEDIA
+This directory is accessed at /site_media/static/ in runserver when DEBUG
is True. It is built with build_static for production environments.
See http://pinaxproject.com/docs/dev/media.html for more information.
@@ -6,6 +6,8 @@
from django.contrib import admin
admin.autodiscover()
+from staticfiles.urls import staticfiles_urlpatterns
+
from pinax.apps.account.openid_consumer import PinaxConsumer
@@ -23,8 +25,5 @@
url(r"^openid/", include(PinaxConsumer().urls)),
)
-
-if settings.SERVE_MEDIA:
- urlpatterns += patterns("",
- url(r"", include("staticfiles.urls")),
- ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+urlpatterns += staticfiles_urlpatterns()
+urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
@@ -9,9 +9,6 @@
DEBUG = True
TEMPLATE_DEBUG = DEBUG
-# tells Pinax to serve media through the staticfiles app.
-SERVE_MEDIA = DEBUG
-
# django-compressor is turned off by default due to deployment overhead for
# most users. See <URL> for more information
COMPRESS = False
@@ -7,7 +7,7 @@ The convention for this directory is:
* js/ — stores Javascript files
* img/ — stores image files
-This directory is accessed at /site_media/static/ in runserver when SERVE_MEDIA
+This directory is accessed at /site_media/static/ in runserver when DEBUG
is True. It is built with build_static for production environments.
See http://pinaxproject.com/docs/dev/media.html for more information.
@@ -6,6 +6,8 @@
from django.contrib import admin
admin.autodiscover()
+from staticfiles.urls import staticfiles_urlpatterns
+
from pinax.apps.account.openid_consumer import PinaxConsumer
@@ -26,8 +28,5 @@
url(r"^announcements/", include("announcements.urls")),
)
-
-if settings.SERVE_MEDIA:
- urlpatterns += patterns("",
- url(r"", include("staticfiles.urls")),
- ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+urlpatterns += staticfiles_urlpatterns()
+urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
@@ -9,9 +9,6 @@
DEBUG = True
TEMPLATE_DEBUG = DEBUG
-# tells Pinax to serve media through the staticfiles app.
-SERVE_MEDIA = DEBUG
-
INTERNAL_IPS = [
"127.0.0.1",
]
@@ -1,8 +1,11 @@
from django.conf import settings
from django.conf.urls.defaults import *
+from django.conf.urls.static import static
from django.shortcuts import render_to_response
from django.template import RequestContext
+from staticfiles.urls import staticfiles_urlpatterns
+
handler500 = "pinax.views.server_error"
@@ -11,8 +14,5 @@
(r"^(.*)$", "pinax.views.static_view")
)
-
-if settings.SERVE_MEDIA:
- urlpatterns = patterns("",
- (r"", include("staticfiles.urls")),
- ) + urlpatterns
+urlpatterns += staticfiles_urlpatterns()
+urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
@@ -9,9 +9,6 @@
DEBUG = True
TEMPLATE_DEBUG = DEBUG
-# tells Pinax to serve media through the staticfiles app.
-SERVE_MEDIA = DEBUG
-
# django-compressor is turned off by default due to deployment overhead for
# most users. See <URL> for more information
COMPRESS = False
@@ -7,7 +7,7 @@ The convention for this directory is:
* js/ — stores Javascript files
* img/ — stores image files
-This directory is accessed at /site_media/static/ in runserver when SERVE_MEDIA
+This directory is accessed at /site_media/static/ in runserver when DEBUG
is True. It is built with build_static for production environments.
See http://pinaxproject.com/docs/dev/media.html for more information.
@@ -6,6 +6,8 @@
from django.contrib import admin
admin.autodiscover()
+from staticfiles.urls import staticfiles_urlpatterns
+
handler500 = "pinax.views.server_error"
@@ -17,8 +19,5 @@
url(r"^admin/", include(admin.site.urls)),
)
-
-if settings.SERVE_MEDIA:
- urlpatterns += patterns("",
- url(r"", include("staticfiles.urls")),
- ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+urlpatterns += staticfiles_urlpatterns()
+urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

4 comments on commit a6c15cb

Owner
brosner commented on a6c15cb Mar 8, 2012

I hate that this change is needed. SERVE_MEDIA served a very important purpose and the fact that upstream decided to change this means we lose functionality. I understand why we needed to do something and this is the easiest fix. Oh well, can't always have your cake and eat it too.

Owner

Yep, I agree it's a shame we had to do this.

Yup I agree this seem a little overhead. I'd suggest we simply leave media files handled
by nginx/apache disregarding DEBUG value... Also i don't really understand the purpose of such a SERVE_MEDIA setting considering django already provide this functionality in django.contrib.staticfiles.

Member

It's completely worthwhile to serve media with runserver in debug mode (no one should have to set up apache/nginx locally to get going with Django), we just removed SERVE_MEDIA since it only worked with previous versions of staticfiles. The only way to serve media now with DEBUG set to True is now to use runserver --insecure.

Please sign in to comment.