Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

serve user-uploaded media with the dev server #39

Merged
merged 1 commit into from

4 participants

@tubaman

We should serve up user-uploaded stuff when running the dev server

@tubaman tubaman serve user-uploaded media with the dev server
We should serve up user-uploaded stuff when running the dev server
53c6b58
@lukeman
Owner

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.

Owner

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.

@chrisdev

I this is great and it should be merged. The behavior of the new version with regards to uploaded media in development confuses many people and I have to keep telling them to add
"+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)"
to their projects urls.py.
I wold be nice if the base projects included this line since it must often be be included manually.
Also this is basically what the version of the django-staticfiles (0.2.0 ) that shipped with the last Pinax release did

@lukeman
Owner

Yeah, we need to get this merged. I'll do this in a bit (either tonight or in the morning) and we'll just remove SERVE_MEDIA altogether. It's not my favorite thing, but it's consistent with staticfiles docs.

@lukeman lukeman merged commit 04c078c into pinax:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 21, 2012
  1. @tubaman

    serve user-uploaded media with the dev server

    tubaman authored
    We should serve up user-uploaded stuff when running the dev server
This page is out of date. Refresh to see the latest.
View
3  pinax/projects/account_project/urls.py
@@ -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)
View
3  pinax/projects/basic_project/urls.py
@@ -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)
View
3  pinax/projects/zero_project/urls.py
@@ -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)
Something went wrong with that request. Please try again.