Django-Oscar-分叉嵌套应用程序

问题描述

我无法派生作为其他Django-oscar应用子集的一部分的Django-oscar应用。对于我要遵循的文档/教程,请查看here

尽管如此,但我成功地分叉了未嵌套在其他应用程序中的应用程序,并相应地更新了已安装的应用程序。以下是部分应用程序,以演示嵌套应用程序的一般模式

'dashboard_folder.dashboard.apps.DashboardConfig','oscar.apps.dashboard.reports.apps.ReportsDashboardConfig','oscar.apps.dashboard.offers.apps.OffersDashboardConfig',

但是,文档(上面链接)没有明确概述如何调用嵌套的应用程序。我以为他们可能会和他们的“父母”自动分叉,但是一个简单的测试(下面的代码)被证明是相反的:

如果我将'oscar.apps.dashboard.reports.apps.ReportsDashboardConfig',更改为 dashboard_folder.dashboard.reports.apps.ReportsDashboardConfig',

我收到以下错误

ModuleNotFoundError: No module named 'dashboard_folder.dashboard.reports'

我发现id尝试了一些有关如何调用嵌套应用程序来对其进行分叉的“受过教育”的猜测,但是不幸的是,以下所有方法均失败了:

manage.py oscar_fork_app offers offers_folder
CommandError: There is no app with the label 'offers'

manage.py oscar_fork_app dashboard.offers offers_folder
CommandError: There is no app with the label 'dashboard.offers'

manage.py oscar_fork_app ReportsDashboard ReportsDashboard_folder
CommandError: There is no app with the label 'ReportsDashboard'

manage.py oscar_fork_app reportsdashboard ReportsDashboard_folder
CommandError: There is no app with the label 'reportsdashboard'

manage.py oscar_fork_app dashboard/reportsdashboard ReportsDashboard_folder
CommandError: There is no app with the label 'dashboard/reportsdashboard'

任何帮助将不胜感激,我不仅仅尝试通过电子邮件发送Django-oscar来寻求帮助,但还有很多尝试,但也许这个问题将来会对其他人有所帮助!

编辑:

这是我的仪表板应用程序配置供参考:

import oscar.apps.dashboard.apps as apps

class DashboardConfig(apps.DashboardConfig):
    name = 'dashboard_folder.dashboard'

所有其他Oscar分支应用程序都遵循相同的通用模式。

解决方法

您是对的,有关此文档的内容不是很清楚。 oscar_fork_app的第一个参数是要分叉的应用程序的应用程序标签。对于顶级应用程序,它类似于offercatalogue,但是对于嵌套应用程序,您需要检查apps.py以便该应用程序看到标签。

如果以oscar.apps.dashboard.reports.apps.ReportsDashboardConfig为例,则其应用程序配置如下:

class ReportsDashboardConfig(OscarDashboardConfig):
    label = 'reports_dashboard'    # <--- this is important

label是用于派生应用程序所需要的。像这样:

python manage.py oscar_fork_app reports_dashboard path/to/your_forks_directory

还请注意,第二个参数必须是所有分叉应用程序所在目录的顶级路径。该目录的子目录必须与Oscar的应用程序结构匹配,并且嵌套的应用程序将被分叉到其中适当的嵌套目录中。

如果在此之后您仍然获得ModuleNotFoundError,则很可能是因为Oscar自动生成的应用name与您的项目结构不太匹配。检查此名称以查看它是否与项目中找到的模块匹配,如果不匹配,请对其进行调整。