Permalink
Browse files

serve user-uploaded media with the dev server

We should serve up user-uploaded stuff when running the dev server
  • Loading branch information...
tubaman committed Jan 21, 2012
1 parent 310c894 commit 53c6b582305d2600bd5a618a51e0fc479bfbf77c
@@ -1,6 +1,7 @@
from django.conf import settings
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
+from django.conf.urls.static import static
from django.contrib import admin
admin.autodiscover()
@@ -26,4 +27,4 @@
if settings.SERVE_MEDIA:
urlpatterns += patterns("",
url(r"", include("staticfiles.urls")),
- )
+ ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
@@ -1,6 +1,7 @@
from django.conf import settings
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
+from django.conf.urls.static import static
from django.contrib import admin
admin.autodiscover()
@@ -29,4 +30,4 @@
if settings.SERVE_MEDIA:
urlpatterns += patterns("",
url(r"", include("staticfiles.urls")),
- )
+ ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
@@ -1,6 +1,7 @@
from django.conf import settings
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
+from django.conf.urls.static import static
from django.contrib import admin
admin.autodiscover()
@@ -20,4 +21,4 @@
if settings.SERVE_MEDIA:
urlpatterns += patterns("",
url(r"", include("staticfiles.urls")),
- )
+ ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

2 comments on commit 53c6b58

@lukeman

This comment has been minimized.

Show comment Hide comment
@lukeman

lukeman Jan 21, 2012

Thanks Ryan. I'm +1 on serving media, but will get at least one other core dev to review before merging.

My only reservation is with the existing Pinax approach here in light of the new contrib staticfiles. Since static() uses DEBUG to determine whether or not to include the url, I'm thinking we should either simply rely on DEBUG explicity for both of static and site media or make sure SERVE_MEDIA is respected for both if we want to continue supporting that.

Thanks Ryan. I'm +1 on serving media, but will get at least one other core dev to review before merging.

My only reservation is with the existing Pinax approach here in light of the new contrib staticfiles. Since static() uses DEBUG to determine whether or not to include the url, I'm thinking we should either simply rely on DEBUG explicity for both of static and site media or make sure SERVE_MEDIA is respected for both if we want to continue supporting that.

@jtauber

This comment has been minimized.

Show comment Hide comment
@jtauber

jtauber Jan 21, 2012

It is a bit of a shame that DEBUG is conflated like this. I always liked SERVE_MEDIA defaulting to DEBUG but allowing you to set it independently too.

It is a bit of a shame that DEBUG is conflated like this. I always liked SERVE_MEDIA defaulting to DEBUG but allowing you to set it independently too.

Please sign in to comment.