Code

Opened 3 years ago

Closed 3 years ago

#15699 closed (invalid)

outdated documentation: demo template concerning login_required causes errors

Reported by: santa 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: UI/UX:

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

Attachments (0)

Change History (1)

comment:1 Changed 3 years ago by lrekucki

  • Keywords outdated removed
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

It's actually the other way around. The documentation you're looking at (judging 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

Last edited 3 years ago by lrekucki (previous) (diff)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.