【问题标题】:Caught AttributeError while rendering: tuple object has no attribute regex渲染时捕获 AttributeError:元组对象没有属性正则表达式
【发布时间】:2012-01-17 12:11:37
【问题描述】:

这是我的 urls.py,目前出现错误:“元组对象没有属性正则表达式”。有什么想法吗?

from django.conf.urls.defaults import *
from ecomstore import settings

urlpatterns = patterns('ecomstore.accounts.views',
                       (r'^register/$', 'register', {'template_name':'registration/register.html', 'SSL':settings.ENABLE_SSL}, 'register'),
                       (r'^my_account/$','my_account', {'template_name':'registration/my_account.html'},'my_account'),
                       (r'^order_details/(?P<order_id>[-\w]+)/$', 'order_details', {'template_name':'registration/order_details.html'}, 'order_details'),
                       (r'^order_info//$', 'order_info', {'template_name':'registration/order_info.html'},'order_info'),
)

urlpatterns += ('django.contrib.auth.views', 
                (r'^login/$','login', {'template_name':'registration/login.html', 'SSL':settings.ENABLE_SSL}, 'login'),
)

【问题讨论】:

  • 您需要在第二组模式上调用patterns(),尽管我不确定这本身会导致该属性错误。

标签: python django


【解决方案1】:

您忘记了第二组 URL 模式周围的模式。它应该是这样的:

urlpatterns += patterns('django.contrib.auth.views', 

【讨论】:

  • 谢谢 - 我已经盯着它看了一个小时:P。有时最容易的就是最难的。
猜你喜欢
  • 2011-10-14
  • 1970-01-01
  • 2019-06-09
  • 2018-04-19
  • 1970-01-01
  • 2011-09-24
  • 1970-01-01
  • 2010-12-02
  • 2021-11-23
相关资源
最近更新 更多