“URL”需要一个非空的第一个参数。在Django 1.5改变的语法,请参阅该文档 [英] 'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs
本文介绍了“URL”需要一个非空的第一个参数。在Django 1.5改变的语法,请参阅该文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用django.contrib.auth登录,但似乎这并不在Django 1.5工作
这是urls.py
i'm trying to login using django.contrib.auth but seems this does not work in Django 1.5 this is urls.py
r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
和本我的模板
1 {% extends "website/base.html" %}
2
3 {% block content %}
4
5 {% if form.errors %}
6 <p>Authentication error</p>
7 {% endif %}
8
9 <form action="{% url django.contrib.auth.views.login %}" method="post">
10 {% for field in form %}
11 <p>
12 {{ field.label_tag }}: {{ field }}
13 {{ field.errors }}
14 </p>
15 {% endfor %}
16 <p><input type="submit" value="Login" /></p>
17 <input type="hidden" name="next" value="{{ next }}" />
18 </form>
我该如何解决?
推荐答案
您想周围的视图名称报价:
You want quotes around the view name:
<form action="{% url "django.contrib.auth.views.login" %}" method="post">
这篇关于“URL”需要一个非空的第一个参数。在Django 1.5改变的语法,请参阅该文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文