title: Logging in an already-registered user in Django
body: <p>I have made the registration part of the login system, but I am unable to make a registered user login. How can I do this?</p>
  
  <p>Here's my code:</p>
  
  <h3>Views.py</h3>
  
  <pre><code>from django.shortcuts import render, redirect
  from django.contrib.auth import authenticate, login
  from django.views.generic import View
  
  
  from .forms import UserForm
  
  # def Success(request):
  #     return render(request, 'success.html')
  
  class UserFormView(View):
      form_class = UserForm
      template_name = 'form.html'
  
      def get(self, request):
          form = self.form_class(None)
          return render(request, self.template_name, {'form': form})
  
      def post(self, request):
          form = self.form_class(request.POST)
  
          if form.is_valid():
              user = form.save(commit=False)
              # cleaned data
              username = form.cleaned_data['username']
              password = form.cleaned_data['password']
              user.save()
              return redirect('success.html')
  
          return render(request, self.template_name, {'form': form})
  </code></pre>
  
  <h3>Urls.py</h3>
  
  <pre><code>from django.conf import settings
  from django.conf.urls import include, url
  from django.conf.urls.static import static
  from django.contrib import admin
  
  
  from .views import UserFormView
  
  
  urlpatterns = [
      url(r'^$', UserFormView.as_view(), name='registraion'),
      url(r'login/', LoginView.as_view(), name='login'),
      #url(r'success/', Success, name='sccuess')
  ]
  </code></pre>
  
  <h3>Forms.html</h3>
  
  <pre><code> Registration Form
  &lt;br&gt;
  &lt;form action="" method="POST"&gt;
  {% csrf_token %}
  {{form.as_p}}
  &lt;button type="submit"&gt;SUBMIT&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>What I basically want is a login page from which I can login in an already-registered user (this login page is different from the page where the user registers). So basically a new view through which a registered user can log in.</p>
  
  <p>I have already made the registration page and the code for it is above. Also after the user is authenticated on the login page he must be redirected to another page (say home.html) and his login information must also we carried to the page where he has been redirected to.</p>