Created
January 21, 2012 17:23
-
-
Save dnoyes/1653345 to your computer and use it in GitHub Desktop.
serving uploaded MEDIA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# settings.py | |
import os | |
VENV_ROOT = os.environ.get('VIRTUAL_ENV', '') | |
MEDIA_ROOT = VENV_ROOT + '/media/' | |
MEDIA_URL = '/media/' | |
# urls.py | |
urlpatterns = patterns('', | |
# ... | |
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) |
Neeeeeever mind. I made the media
pattern FIRST and all is well.
urlpatterns = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += ( ... )
Cool
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While running in an activated virtualenv, I hit:
http://localhost:8000/media/teams/awesome-pants.jpg
And I get a 404.
awesome-pants.jpg
was uploaded successfully via thedjango admin
.