问题描述
|
我正在尝试重用此处显示的模板作为我的登录页面的基础,但是当我运行它时,出现此错误:
\'url\' is not a valid tag library
我需要做一些特殊的设置吗?
模板中令人反感的行是:
{% load url from future %}
如果重要的话,我使用的是Django 1.2。
解决方法
1.3 docs
与
1.2 docs
在Django 1.3之前没有{% load url from future %}
。
从1.2 docs
使用它:
{% extends \"base.html\" %}
{% block content %}
{% if form.errors %}
<p>Your username and password didn\'t match. Please try again.</p>
{% endif %}
<form method=\"post\" action=\"{% url django.contrib.auth.views.login %}\">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
<input type=\"submit\" value=\"login\" />
<input type=\"hidden\" name=\"next\" value=\"{{ next }}\" />
</form>
{% endblock %}
,在django 1.9中,默认情况下会加载url标记,因此您只需删除load语句即可。
RemovedInDjango19Warning: Loading the `url` tag from the `future` library is deprecated and will be removed in Django 1.9. Use the default `url` tag instead.