【问题标题】:Error after adding django form-wizard into urls.py将 django form-wizard 添加到 urls.py 后出错
【发布时间】:2012-08-23 18:39:46
【问题描述】:

我的应用程序的 urls.py 中有这段代码:

urlpatterns = patterns('john_shop.checkout.views',
    (r'^wizard/$', ContactWizard.as_view([CheckoutForm, PaymentForm]),'checkout_wizard'),
)

如果 FormWizard 保持未注释状态,我会收到此错误:

dictionary update sequence element #0 has length 1; 2 is requiredRequest Method:    GET
Request URL:    http://john-shop.ru/category/new-balance-501/
Django Version: 1.4
Exception Type: ValueError
Exception Value:    dictionary update sequence element #0 has length 1; 2 is required
Exception Location: /usr/local/lib/python2.6/dist-packages/Django-1.4-py2.6.egg/django/core/urlresolvers.py in _populate, line 258
Python Executable:  /usr/bin/python
Python Version: 2.6.6

什么会导致这个问题?我知道 Error 没有说明 urls.py,但如果我注释掉该字符串,站点仍然可以正常运行。

附:我需要将其命名以从购物车中获取重定向并继续用户结帐。

【问题讨论】:

    标签: django django-urls django-formwizard


    【解决方案1】:

    你说错了。这是一个正确的:

    urlpatterns = patterns('',
        (r'^ wizard/$', ContactWizard.as_view([CheckoutForm, PaymentForm])),
    )
    

    https://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/#hooking-the-wizard-into-a-urlconf

    【讨论】:

    • 更改为:urlpatterns += patterns('', (r'^wizard/$', ContactWizard.as_view([CheckoutForm, PaymentForm]),'checkout'), ),我仍然遇到同样的错误。我猜那是因为网址的名称,但我不知道如何解决它。
    • 愚蠢的问题:如果你注释掉 urls 行,你还会得到错误吗?
    猜你喜欢
    • 1970-01-01
    • 2014-01-29
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    • 1970-01-01
    • 2014-11-23
    • 2012-05-17
    • 1970-01-01
    相关资源
    最近更新 更多