开发者

Django - {% load url from future %} yields error "'url' is not a valid tag library"

开发者 https://www.devze.com 2023-02-25 13:05 出处:网络
I\'m trying to reuse the开发者_开发知识库 template shown here as a basis for my login page but when I run it I get this error:

I'm trying to reuse the开发者_开发知识库 template shown here as a basis for my login page but when I run it I get this error:

'url' is not a valid tag library

Is there some special setting I need to do?

The offending line in the template is:

{% load url from future %}

I'm on Django 1.2 if it matters.


In django 1.9 the url tag is loaded by default so you can simply remove the load statement.

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.


1.3 docs

vs

1.2 docs

There is no {% load url from future %} until django 1.3.

use this from the 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 %}
0

精彩评论

暂无评论...
验证码 换一张
取 消