NoReverseMatch at /accounts/login/ form action query?
<p>Im trying to learn django, but i cant find the answer to this anywhere, or at-least not in simple terms! im trying to implement the included login view in my project and ive tried using the example html that the documentation uses and i get this error.</p>

<pre><code>Template error:
In template  
C:\Users\Owner\Documents\django\mysite\templates\registration\login.html, error at line 14
Reverse for 'login' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []   4 : 
5 : {% if next %}
6 :     {% if user.is_authenticated %}
7 :     &lt;p&gt;Your account doesn't have access to this page. To proceed,
8 :     please login with an account that has access.&lt;/p&gt;
9 :     {% else %}
10 :     &lt;p&gt;Please login to see this page.&lt;/p&gt;
11 :     {% endif %}
12 : {% endif %}
13 : 
14 : &lt;form method="post" action=" {% url 'login' %} "&gt;
15 : {% csrf_token %}
16 : &lt;table&gt;
17 : &lt;tr&gt;
18 :     &lt;td&gt;{{ form.username.label_tag }}&lt;/td&gt;
19 :     &lt;td&gt;{{ form.username }}&lt;/td&gt;
20 : &lt;/tr&gt;
21 : &lt;tr&gt;
22 :     &lt;td&gt;{{ form.password.label_tag }}&lt;/td&gt;
23 :     &lt;td&gt;{{ form.password }}&lt;/td&gt;
24 : &lt;/tr&gt;
</code></pre>

<p>what i dont understand is what does " Action="{% url 'login' %}" actually do? i cant find a definitve answer of where it is actully looking for that.  this is my blog/views.py file</p>

<pre><code>from django.shortcuts import render
from django.views import generic
from .models import Post
from django.utils import timezone
from django.contrib.auth.decorators import login_required
from django.http import request, HttpResponse
from django.template import loader
 # Create your views here.
class ListViews(generic.ListView):
    template_name= 'blog/list.html'
    context_object_name= 'latest_blog_posts'

    def get_queryset(self):
        return Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')[:5]

@login_required
def DetailView(request,pk):
    model = Post
    data_list = Post.objects.get(id=pk)
    template = loader.get_template('blog/detail.html')
    context = {
        'post':data_list,
    }
    return HttpResponse(template.render(context,request))
#def get_queryset(self):
#return Post.objects.filter(published_date__lte=timezone.now())
</code></pre>

<p>and this is my mysite/urls.py file:</p>

<pre><code>from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth import views as auth_views

urlpatterns = [
url(r'^polls/', include('polls.urls', namespace="polls")),
url(r'^blog/', include('blog.urls', namespace="blog")),
url(r'^admin/', admin.site.urls),
url(r'^accounts/login/$', auth_views.login),
]
</code></pre>

<p>and ive already tried accounts/login in the action field of the form and that gives the same error. any ideas will be very much appreciated! thanks!</p>

<p>Action="{% url 'login' %} : this means when you submit the form it will take you search for the url named 'login' in your urls.py and execute the view. but there isnt anything named login in your urls.py.you can try to edit the last line of urls.py as :
        url(r'^accounts/login/$', auth_views.login, name='login'), 
or edit template file as:
        &lt; form method="post" action="."></p>

python django