import os
DIRNAME = os.path.dirname(__file__)# 1)去掉文件名的路径 2)__file__为本settings.py文件
MEDIA_ROOT = os.path.join(DIRNAME, '静态路径')
网站目录规范:
example.com/
-README
-settings.py
-urls.py
-APP1/
-APP2/
+docs/
#This will hold the documentation for your project
+static/
#In production this will be the root of your MEDIA_URL
+css/
+js/
+images/
+tests/
#Project level tests (Each app should also have tests)
+uploads/
+content imgs, etc
+templates/
#This area is used to override templates from your reusable apps
+flatpages/
+comments/
+example/
+app1/
+app2/

本文介绍了Django项目的目录结构规范及其配置方法,包括如何在settings.py中设置相对路径及网站目录布局,对于理解并搭建Django项目具有指导意义。
1225

被折叠的 条评论
为什么被折叠?



