Home
Sign Up
Sign In
推荐学习书目
›
Learn Python the Hard Way
Python Sites
›
PyPI
- Python Package Index
›
http://diveintopython.org/toc/index.html
›
Pocoo
值得关注的项目
›
PyPy
›
Celery
›
Jinja2
›
Read the Docs
›
gevent
›
pyenv
›
virtualenv
›
Stackless Python
›
Beautiful Soup
›
结巴中文分词
›
Green Unicorn
›
Sentry
›
Shovel
›
Pyflakes
›
pytest
Python 编程
›
pep8 Checker
Styles
›
PEP 8
›
Google Python Style Guide
›
Code Style from The Hitchhiker's Guide
V2EX
›
Python
django中的settings.py
zzxworld
·
Apr 18, 2012
· 5359 views
This topic created in 5317 days ago, the information mentioned may be changed or developed.
在这个文件中可以配置TEMPLATE_DIRS来自定义模块目录,但是注释中说一定要使用绝对路径。因为会在不同的电脑上开发同一个项目,请问大家怎么解决这个文件在版本库中的问题?
文件
绝对路径
库中
7 replies
•
1970-01-01 08:00:00 +08:00
xiaket
Apr 18, 2012
1
app下面建templates目录就行了?
zzxworld
OP
Apr 18, 2012
2
@
xiaket
不行的,因为要使用绝对路径,两台电脑中app的主目录不一致。
c
Apr 18, 2012
3
import os
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
bhuztez
Apr 18, 2012
4
你随便搜一下就知道了,一般建议类似这样
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIRS = (
os.path.join(PROJECT_PATH, 'templates'),
)
zzxworld
OP
Apr 18, 2012
5
@
c
@
bhuztez
茅塞顿开,谢了。
bhuztez
Apr 18, 2012
6
@
c
建议用 import os.path,还真碰到过 import os 之后 os.path 没的情况。
c
Apr 18, 2012
7
@
bhuztez
谢谢提醒,我学的比较晚,最早的版本就是2.5,一直都是import os,以后要改一改。
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Privacy
·
Solana
·
4310 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 28ms ·
UTC 02:08
·
PVG 10:08
·
LAX 18:08
·
JFK 21:08
♥ Do have faith in what you're doing.
❯