Django 不包含已安装应用程序中的 urls.py
我收到以下错误:
Caught NoReverseMatch while rendering: Reverse for 'satchless-checkout-prepare-order' with arguments '()' and keyword arguments '{}' not found.
但我安装的应用程序中有 satchless.contrib.checkout.common
。 satchless.contrib.checkout.common
中有一个 urls.py
,其中包含:
from django.conf.urls.defaults import patterns, url
from .views import confirmation, prepare_order, reactivate_order
urlpatterns = patterns('',
url(r'^prepare/$', prepare_order, {'typ': 'satchless_cart'},
name='satchless-checkout-prepare-order'),
url(r'^(?P<order_token>\w+)/confirmation/$', confirmation,
name='satchless-checkout-confirmation'),
url(r'^(?P<order_token>\w+)/reactivate/$', reactivate_order,
name='satchless-checkout-reactivate-order'),
)
为什么我无法调用 {% url satchless-checkout-prepare-order %}
来自我的模板?
I am getting the error below:
Caught NoReverseMatch while rendering: Reverse for 'satchless-checkout-prepare-order' with arguments '()' and keyword arguments '{}' not found.
But I have satchless.contrib.checkout.common
in my installed apps. Within satchless.contrib.checkout.common
is a urls.py
which contains:
from django.conf.urls.defaults import patterns, url
from .views import confirmation, prepare_order, reactivate_order
urlpatterns = patterns('',
url(r'^prepare/
Why am I not able to call {% url satchless-checkout-prepare-order %}
from my template?
, prepare_order, {'typ': 'satchless_cart'},
name='satchless-checkout-prepare-order'),
url(r'^(?P<order_token>\w+)/confirmation/
Why am I not able to call {% url satchless-checkout-prepare-order %}
from my template?
, confirmation,
name='satchless-checkout-confirmation'),
url(r'^(?P<order_token>\w+)/reactivate/
Why am I not able to call {% url satchless-checkout-prepare-order %}
from my template?
, reactivate_order,
name='satchless-checkout-reactivate-order'),
)
Why am I not able to call {% url satchless-checkout-prepare-order %}
from my template?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否已将其包含在根 urlconf 中?
你的主 urls.py 文件中有这样的内容:
Have you included it from your root urlconf?
Something like this in your main urls.py file:
您不必在 INSTALLED_APPS 中包含
satchless.contrib.checkout.common
。它不是真正的应用程序,它是 python 包,其中包含多步和单步结账应用程序的常见视图/装饰器。如果您查看 satchless/contrib/checkout/multistep/urls.py 或 satchless/contrib/checkout/singlestep/urls.py 您可以看到两者都包含来自 common/urls.py 的模式:
您要做的就是选择 checkout方法(假设是多步骤),将其添加到 INSTALLED_APPS 并包含适当的 url:
You don't have to include
satchless.contrib.checkout.common
in your INSTALLED_APPS. It's not really app, it's python package which contains common views/decorators for multistep and singlstep checkout apps.If you look into satchless/contrib/checkout/multistep/urls.py or satchless/contrib/checkout/singlestep/urls.py you can see that both including patterns from common/urls.py:
What you have to do is to choose checkout method (let say multistep), add it to INSTALLED_APPS and include appropriate urls: