V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
stackpop
V2EX  ›  Python

stackoverflow上没人回答,请教V2EXer~~~关于django的包管理

  •  
  •   stackpop ·
    sjtubinlong · 2012-09-11 11:55:21 +08:00 · 3299 次点击
    这是一个创建于 4246 天前的主题,其中的信息可能已经有所发展或是发生改变。
    I generate a django project and its directory structure is like the following:

    -myproject

    --__init__.py

    --settings.py

    --rooturls.py

    --dbUtils.py

    --app1

    ---__init__.py

    ---views.py

    ---urls.py

    --app2

    ---__init__.py

    ---views.py

    ---urls.py
    I want to import dbUtils in my apps , so I configure in my settings.py:

    PROJECT_ROOT = os.path.dirname(__file__)
    sys.path.insert(0, PROJECT_ROOT)
    However, the program still can't find the moudle.
    2 条回复    1970-01-01 08:00:00 +08:00
    bigeagle
        1
    bigeagle  
       2012-09-11 13:08:31 +08:00
    PROJECT_ROOT = os.path.dirname( os.path.abspath(__file__) )
    ccp0101
        2
    ccp0101  
       2012-09-12 15:25:09 +08:00
    我的Django项目写的是

    SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5374 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 03:41 · PVG 11:41 · LAX 20:41 · JFK 23:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.