Code

Opened 2 years ago

Closed 2 years ago

#18720 closed Uncategorized (needsinfo)

Code sample for views.html template causes NoReverseMatch error

Reported by: anonymous Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal 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

The page in question is

https://docs.djangoproject.com/en/1.4/topics/auth/

The code sample for views.html will cause a NoReverseMatchError due to the single quotes in the argument to the bolded url tag below:

{% 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' %}">
{% 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 %}

Removing the quotes fixes the error.

Attachments (0)

Change History (3)

comment:1 Changed 2 years ago by prseshad@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 2 years ago by charettes

Are you sure you put the {% load url from future %} in your template?

comment:3 Changed 2 years ago by aaugustin

  • Resolution set to needsinfo
  • Status changed from new to closed

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.