django静态路径配置

1. settings.py

import os



ROOT_PATH = os.path.dirname(os.path.abspath(__file__))



...



STATIC_PATH = os.path.join(ROOT_PATH,'content').replace('\\','/')

STATIC_URL = '/content/'



...

...

2. urls.py

from django.conf import settings



...





urlpatterns = patterns('',

    ...

    (r'^content/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.STATIC_PATH})

    ...

)

  

你可能感兴趣的:(django)