Django 不包含已安装应用程序中的 urls.py

发布于 2024-11-18 02:31:43 字数 944 浏览 3 评论 0原文

我收到以下错误:

Caught NoReverseMatch while rendering: Reverse for 'satchless-checkout-prepare-order' with arguments '()' and keyword arguments '{}' not found.

但我安装的应用程序中有 satchless.contrib.checkout.commonsatchless.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

扶醉桌前 2024-11-25 02:31:43

您是否已将其包含在根 urlconf 中?

你的主 urls.py 文件中有这样的内容:

url(r'^foo/' include('satchless.urls')),

Have you included it from your root urlconf?

Something like this in your main urls.py file:

url(r'^foo/' include('satchless.urls')),
巴黎夜雨 2024-11-25 02:31:43

您不必在 INSTALLED_APPS 中包含 satchless.contrib.checkout.common。它不是真正的应用程序,它是 python 包,其中包含多步和单步结账应用程序的常见视图/装饰器。

如果您查看 satchless/contrib/checkout/multistep/urls.py 或 satchless/contrib/checkout/singlestep/urls.py 您可以看到两者都包含来自 common/urls.py 的模式:


from ..common.urls import urlpatterns

urlpatterns = urlpatterns + patterns('',
...

您要做的就是选择 checkout方法(假设是多步骤),将其添加到 INSTALLED_APPS 并包含适当的 url:


settings.py:

INSTALLED_APPS = (
...
    'satchless.contrib.checkout.multistep',
...
)


urls.py:

urlpatterns = patterns(
...
    url('^checkout/', 'satchless.contrib.checkout.multistep.urls')
...
)

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:


from ..common.urls import urlpatterns

urlpatterns = urlpatterns + patterns('',
...

What you have to do is to choose checkout method (let say multistep), add it to INSTALLED_APPS and include appropriate urls:


settings.py:

INSTALLED_APPS = (
...
    'satchless.contrib.checkout.multistep',
...
)


urls.py:

urlpatterns = patterns(
...
    url('^checkout/', 'satchless.contrib.checkout.multistep.urls')
...
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文