【问题标题】:Can I pass data through two different django projects?我可以通过两个不同的 django 项目传递数据吗?
【发布时间】:2019-01-04 18:02:13
【问题描述】:

在 otree 调查之后,我从子进程另一个 django 应用程序开始,特别是 django-oscar 商店。它在另一个端口上运行。 现在,我想将调查中的一些数据(第一个应用程序,otree)传递给商店(第二个应用程序,django-oscar)。

我在 app2/views.py 中试过这个:

from survey.models import Player

class CatalogueView(TemplateView):
    """
    Browse all products in the catalogue
    """
    model = Player
    context_object_name = "products"
    template_name = 'catalogue/browse.html'

但我只是得到这个错误:

ModuleNotFoundError: 没有名为“otree”的模块

我还尝试导入otree.api,并将otree 放入installed_apps。

任何想法,如何处理?

【问题讨论】:

  • 你研究过redis吗?
  • 我只是从我的其他 otree 实验中知道来自 heroku 的 redis,但现在我正在本地工作/测试。

标签: python django project otree


【解决方案1】:

解决这个问题有点不同。 我已经放弃了子流程,而是使用 django REST 框架创建了一个 API。来回传递参数是最好的方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    • 2020-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-19
    相关资源
    最近更新 更多