Django_Media - WBowam/wbowam.github.com GitHub Wiki

Date: 2013-09-14 Title: Django Media 配置(方法一) Tags: Django Category: It

Env:
  • django==1.4.5
  • python==2.7
  • ubuntu==13.04

django 的Static 和 Media配置之Media

settings.py

##added by Tulpar,20140514
import os
settings_dir = os.path.dirname(__file__)
PROJECT_ROOT = os.path.abspath(os.path.dirname(settings_dir))

MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'public/media/')
MEDIA_URL = '/media/'

urls.py


##added by Tulpar,20140514
from django.conf import settings

urlpatterns += patterns('',
    url(r"^media/(?P<path>.*)$","django.views.static.serve",{"document_root": settings.MEDIA_ROOT,}),
)
⚠️ **GitHub.com Fallback** ⚠️