title: Why is my URL not changing to my render template name?
body: <p>I noticed that my URL is not correct after login. How can I do this properly?</p>
  
  <p>Current output URL: </p>
  
  <p><a href="http://127.0.0.1:8000/login_user/" rel="nofollow noreferrer">http://127.0.0.1:8000/login_user/</a></p>
  
  <p>The correct output URL must be:</p>
  
  <p><a href="http://127.0.0.1:8000/" rel="nofollow noreferrer">http://127.0.0.1:8000/</a></p>
  
  <p>How can I achieve this?</p>
  
  <p>login.html:</p>
  
  <pre><code> &lt;form class="form-horizontal" role="form" action="{% url 'ksvt:login_user'%}" method="post" enctype="multipart/form-data"&gt;
                      {% csrf_token %}
                      &lt;div class="form-group"&gt;
                          &lt;label class="control-label col-sm-2" for="id_username"&gt;
                              Username:
                          &lt;/label&gt;
                          &lt;div class="col-sm-10"&gt;
                              &lt;input id="id_username" maxlength="30" name="username" type="text"&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label class="control-label col-sm-2" for="id_password"&gt;
                              Password:
                          &lt;/label&gt;
                          &lt;div class="col-sm-10"&gt;
                              &lt;input id="id_password" maxlength="30" name="password" type="password"&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          &lt;div class="col-sm-offset-2 col-sm-10"&gt;
                              &lt;button type="submit" class="btn btn-success"&gt;Submit&lt;/button&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>from django.conf.urls import url
  from . import views
  
  app_name = 'ksvt'
  
  urlpatterns = [
      url(r'^$', views.IndexView.as_view(), name='index'),
      url(r'^register/$', views.register, name='register'),
      url(r'^login_user/$', views.LoginView.as_view(), name='login_user'),
      url(r'^logout_user/$', views.LogoutView.as_view(), name='logout_user'),
  ]
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>class LoginView(TemplateView):
  template_name = 'ksvt/index.html'
  
  def post(self, request):
      username = request.POST['username']
      password = request.POST['password']
      user = authenticate(username=username, password=password)
      if user is not None:
          if user.is_active:
              login(request, user)
              locations = Location.objects.all()
              return render(request, self.template_name, {'locations': locations})
          else:
              return render(request, self.template_name, {'error_message': 'Your account has been disabled'})
      else:
          return render(request, 'ksvt/login.html', {'error_message': 'Invalid login'})
  </code></pre>