将 Satchmo 与现有 django 项目集成

发布于 2024-07-23 08:03:35 字数 308 浏览 3 评论 0原文

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

I have a running django project and i want to integrate Satchmo with that project. Problem is that instead of putting satchmo into my site-packages directory, i want it to be used as a django app i.e all the satchmo apps like product, shipping, satchmo-utils etc are to be in a directory say satchmo-apps in my django project. But by doing this i get an error that no module found: satchmo_utils or whatever is within the satchmo-apps. And i don't want to put the satchmo apps(product, shipping,tax etc) directly into the python/django path. so please help me out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听,心雨的声音 2024-07-30 08:03:35

您的意思是您不想将其添加到 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__))

Do you mean you don't want to add it to the PYTHONPATH environment variable?

If so, you could have the parent directory of where you have Satchmo installed added to the python module search path at runtime, so that it applies to your project only.
Say you have the Satchmo package copied to your project directory like this:

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

Then you can use the following at the start of your settings.py to make Python find it:

import sys
import os
sys.path.insert(0, os.path.dirname(__file__))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文