【问题标题】:integrating Satchmo with existing django project将 Satchmo 与现有 django 项目集成
【发布时间】:2010-10-31 06:52:24
【问题描述】:

我有一个正在运行的 django 项目,我想将 Satchmo 与该项目集成。问题是,我不想将 satchmo 放入我的站点包目录中,而是希望它用作 django 应用程序,即所有 satchmo 应用程序(如产品、运输、satchmo-utils 等)都位于我的目录中,例如 satchmo-apps django 项目。但是通过这样做,我得到一个没有找到模块的错误:satchmo_utils 或 satchmo-apps 中的任何内容。而且我不想将 satchmo 应用程序(产品、运输、税收等)直接放入 python/django 路径。所以请帮帮我。

【问题讨论】:

  • 你为什么不想把应用程序放到你的 pythonpath 中呢?这是显而易见的事情。

标签: django satchmo


【解决方案1】:

您的意思是您不想将其添加到 PYTHONPATH 环境变量中?

如果是这样,您可以在运行时将安装 Satchmo 的父目录添加到 python 模块搜索路径,以便它仅适用于您的项目。 假设您将 Satchmo 包复制到您的项目目录,如下所示:

project/
 +-settings.py
 +-satchmo/
     +-apps/
     +-projects/
     +-static/

然后您可以在settings.py 的开头使用以下内容让 Python 找到它:

import sys
import os
sys.path.insert(0, os.path.dirname(__file__))

【讨论】:

    猜你喜欢
    • 2011-06-03
    • 1970-01-01
    • 2011-12-07
    • 1970-01-01
    • 1970-01-01
    • 2020-05-04
    • 1970-01-01
    • 2011-09-22
    • 1970-01-01
    相关资源
    最近更新 更多