Opened 14 years ago

Closed 14 years ago

#15699 closed (invalid)

outdated documentation: demo template concerning login_required causes errors

Reported by: Gerald Senarclens de Grancy Owned by: nobody
Component: Documentation Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.decorators.login_required there's a sample template for creating a login form. The form starts with
"""
{% extends "base.html" %}
{% load url from future %}

{% 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' %}">
"""
However, in current versions of django, 'url' is a build-in tag and doesn't require {% load url from future %}. Actually, having this causes a TemplateSyntaxError at /accounts/login/ - 'url' is not a valid tag library error.

There seems to be another issue as well: {% url 'django.contrib.auth.views.login' %} leads to a TemplateSyntaxError at /accounts/login/ - Caught NoReverseMatch while rendering error. To the best of my knowledge this is due to the single quote around the view's name. Afaik it should say {% url django.contrib.auth.views.login %} instead.

  • reproduce:

create a tiny django app and apply the @login_required decorator as outlined in http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.decorators.login_required

  • expected result:

following the explanations including the demo template works

  • actual result:

'url' is not a valid tag library

Change History (1)

comment:1 by Łukasz Rekucki, 14 years ago

Keywords: outdated removed
Resolution: invalid
Status: newclosed

It's actually the other way around. The documentation you're looking at (juidging from the /dev/... part in the URL) is for the *latest* version of Django. The recently released Django 1.3 made some changes to the {% url %} tag. See the release notes. If you're using Django 1.2, you should be looking at the 1.2 docs

Version 0, edited 14 years ago by Łukasz Rekucki (next)
Note: See TracTickets for help on using tickets.
Back to Top