AttributeError:'str'对象没有属性'regex' [英] AttributeError: 'str' object has no attribute 'regex'

查看:158
本文介绍了AttributeError:'str'对象没有属性'regex'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用旧版 django 1.3.1 ,在模板中使用网址名称模式时遇到问题。

working with legacy django 1.3.1 , having problem in using the url name patterns in the template.

urls。 py

urlpatterns = patterns(
    'project.views',

    url(r'^web/login/', 'login', name="web_login"),

)

视图中渲染模板,如:

return render_to_response('index.html', context_instance=RequestContext(request))

/ strong>使用url命名模式,如

in template using the url naming pattern like

<form id="loginForm" action="{% url web_login %}" method="POST">

渲染模板时获取错误

AttributeError:'str'对象没有属性'regex'

AttributeError: 'str' object has no attribute 'regex'

推荐答案

你忘了一些引号。

action="{% url 'web_login' %}"

这篇关于AttributeError:'str'对象没有属性'regex'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆