Opened 3 years ago

Closed 3 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


The page in question is

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 %}

<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>


<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>


<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" />

{% endblock %}

Removing the quotes fixes the error.

Change History (3)

comment:1 Changed 3 years ago by prseshad@…

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

comment:2 Changed 3 years ago by charettes

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

comment:3 Changed 3 years ago by aaugustin

  • Resolution set to needsinfo
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top