title: Login cannot be done in my app
body: <p>Login cannot be done in my app.I wrote in views.py</p>
  
  <pre><code>from django.shortcuts import render,redirect
  from django.urls import reverse
  from app.forms import RegisterForm,LoginForm
  from app.models import Data
  from app.forms import DataForm
  from django.db.models import Q
  
  def index(request):
      data = Data.objects.order_by('-created_at')
      form = RegisterForm()
      loginform = LoginForm()
      dataform = DataForm()
      return render(request, 'index.html',{'data':data,'form':form,'loginform':loginform,'dataform':dataform,'user': request.user})
  </code></pre>
  
  <p>in index.html</p>
  
  <pre><code>&lt;section id="top"&gt;
                  {% if user and not user.is_anonymous %}
                          &lt;p&gt;Hello&lt;/p&gt;
                          &lt;h3&gt;{{ user.username }}&lt;/h3&gt;
                  {% else %}
                              &lt;form action="{% url 'app:index' %}" method="POST"&gt;
                                      {{ loginform.non_field_errors }}
  
                                      {% for field in loginform %}
                                          {{ field }}
                                          {{ field.errors }}
                                      {% endfor %}
  
                                  &lt;button type="submit"&gt;LOGIN&lt;/button&gt;
                                  {% csrf_token %}
                              &lt;/form&gt;
                  {% endif %}
  &lt;/section&gt;
  </code></pre>
  
  <p>in forms.py</p>
  
  <pre><code>from django import forms
  from django.contrib.auth.forms import (
      AuthenticationForm
  )
  class LoginForm(AuthenticationForm):
      def __init__(self, *args, **kwargs):
          super().__init__(*args, **kwargs)
          for field in self.fields.values():
              field.widget.attrs['class'] = 'form-control'
              field.widget.attrs['placeholder'] = field.label
  </code></pre>
  
  <p>in child's app's urls.py</p>
  
  <pre><code>from django.urls import include, path
  from . import views
  from django.contrib.auth.views import login
  
  app_name = 'app'
  urlpatterns = [
      path('index', views.index,name='index'),
  ]
  </code></pre>
  
  <p>in parent's app's urls.py</p>
  
  <pre><code>from django.contrib import admin
  from django.urls import path,include
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('app/',include('app.urls') ),
  ]
  </code></pre>
  
  <p>When I login from loginform,if statement of <code>{% if user and not user.is_anonymous %}</code> did not become true.But when I login in admin site, the statement become true.When I put LOGIN button, no error happens.I really cannot understand what is wrong.How should I fix this?</p>