python - fork 运输应用程序在 Django oscar 中没有效果

标签 python django python-3.x django-oscar

我使用 oscar_fork_app 命令将我的运输应用程序 fork 到一个名为 forked_apps 的文件夹中,并添加到 settings.py get_core_apps(['forked_apps.shipping']) 中,我只想在此链接中的文档:https://django-oscar.readthedocs.io/en/latest/howto/how_to_configure_shipping.html .

init.py 中,我已经存在以下代码:

default_app_config = 'forked_apps.shipping.config.ShippingConfig'

在repository.py中我是这样写的:

from oscar.apps.shipping import repository
from .methods import *


class Repository(repository.Repository):

    def get_available_shipping_methods(
            self, basket, user=None, shipping_addr=None,
            request=None, **kwargs):
        methods = (Standard())
        print("\n\nFetch availble shipping methods")
        if shipping_addr:
            # Express is only available in the UK
            methods = (Standard(), Express())

        return methods

在methods.py中我写了:

from decimal import Decimal as D
from oscar.apps.shipping import methods
from oscar.core import prices

class Standard(methods.FixedPrice):
    code = 'standard'
    name = 'Standard shipping'
    charge_excl_tax = D('5.00')

class Express(methods.FixedPrice):
    code = 'express'
    name = 'Express shipping'
    charge_excl_tax = D('10.00')

应该发生的是,shipping_methods.html 页面应该显示,但输入送货地址后,它会直接转到付款详细信息页面;这种情况通常只有在没有定义运输方式的情况下才会发生,但我在上面的代码中实现了两种运输方式:标准运输方式和 express 方式。我不知道如何实现这一点,甚至打印语句也不起作用。 我还必须编写其他额外的代码吗?

如果您已经实现了,有人可以提供一些代码的解决方案吗?

最佳答案

从设置中删除奥斯卡应用程序。

例如:

#oscar.apps.checkout
#oscar.apps.shipping

等等

关于python - fork 运输应用程序在 Django oscar 中没有效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51265182/

相关文章:

python - 是否有相当于 MATLAB 的 datacursormode 的 matplotlib?

python - django模型中的自定义保存方法和登录问题

python - 从网站结果中抓取表格为空

python - 使用Popen执行scp,无需输入密码

php - 从 PHP 运行脚本时,RPi GPIO 控制丢失(没有任何错误)

python - 如何计算 Python 中不包括注释和文档字符串的代码行数?

django - 如何进行翻译?

django - 为什么我在 Heroku 上有这么多使用 CloudAMQP 的 Celery 消息?

python - 查找与近似用户输入值对应的键

Python - 将 numpy 数组转换为 JSON