我使用 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/