title: Django User Registration Authentication Problem
body: <p>Please I am new to Django and user registration is giving me serious headache. The UserCreationForm displays on the page but does not display any errors even when I deliberately pass in wrong and submit passwords.It just refreshes. It does not show errors like password too short etc unlike the login page.<br/></p>
  <h2>Urls.py for Main Project</h2>
  <pre><code>from django.contrib import admin
  from django.urls import path,include
  urlpatterns = [
  path('admin/', admin.site.urls),
  path('accounts/',include('django.contrib.auth.urls')),
  path('',include('account.urls')),
  ]
  </code></pre>
  <h3>Urls.py for account_app</h3>
  <pre><code>from django.urls import path
      from .views import home,register
      urlpatterns = [
      path('',home,name='home'),
      path('register/',register,name='register'),]
  </code></pre>
  <h3>Views.py for account_app</h3>
  <pre><code> from django.shortcuts import render,redirect
      from django.contrib.auth.forms import UserCreationForm
      from django.contrib.auth import authenticate,login
      def home(request):
          return render(request,'base.html')
      def register(request):
          if request.method == 'POST':
              form = UserCreationForm(request.POST)
              if form.is_valid():
                  form.save()
                  username = form.cleaned_data['username']
                  password = form.cleaned_data['password1']
                  user =authenticate(username=form,password=password)
                  login(request,user)
                  return redirect('home')
            else:
                form = UserCreationForm()
            form = UserCreationForm()
         return render(request,'registration/register.html',{'form':form})
  </code></pre>
  <h3>Template folder looks like this</h3>
  <pre><code> +templates
          +registration
              +register.html
  </code></pre>
  <h3>Register.html code</h3>
  <pre><code>&lt;!DOCTYPE html&gt;
      &lt;html lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
        &lt;head&gt;
          &lt;meta charset=&quot;utf-8&quot;&gt;
          &lt;title&gt;Register&lt;/title&gt;
        &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Registration Page&lt;/h1&gt;
          &lt;form method=&quot;POST&quot; action=&quot;{%url 'register' %}&quot;&gt;
            {%csrf_token %}
            {% if form.errors %}
                &lt;p&gt;There are errors in the form    &lt;/p&gt;
            {% endif %}
            {{form}}
            &lt;button type=&quot;submit&quot; name=&quot;button&quot;&gt;Submit&lt;/button&gt;
            &lt;/form&gt;
           &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>