title: How to fix "dictionary update sequence element # 0 has length 104; 2 is required" error
body: <p>I want to create a login page, when the username and password are incorrect there is this error "dictionary update sequence element # 0 has length ... is required". How to correct this error?</p>
  
  <pre><code>forms.py
  class LoginForm(forms.Form):
      username = forms.CharField(max_length=250, required=False)
      password = forms.CharField(max_length=250, required=False)
  
  views.py
  class LoginView(View):
      template_name = 'login/index.html'
      form_class = LoginForm
  
      def get(self, request):
          form = self.form_class()
          return render(request, self.template_name, {'form': form})
  
      def post(self, request):
          form = self.form_class(request.POST)
          if form.is_valid():
              username = form.cleaned_data['username']
              password = form.cleaned_data['password']
              user = authenticate(username=username, password=password)
              if user is not None:
                  login(request, user)
                  next_var = request.GET.get('next')
                  # redirect to url in next var else return to login home page
                  return redirect('%s' % next_var) if next_var else redirect('%s' % settings.LOGIN_REDIRECT_URL)
          return render(request, self.template_name, {'form': form})
  
  </code></pre>
  
  <pre><code>When the fields are not filled there is this error "dictionary update sequence element #0 has length 104; 2 is required" that appears. but when I log in and I go back to the login page to log in without anything filled in I'm reported that the fields are not filled
  </code></pre>
  
  <p>This is my urls.py</p>
  
  <pre><code>from django.urls import path, include
  
  from .views import login, signup, logout, settings, profile
  
  urlpatterns = [
      path('signup/', signup.SignupView.as_view(), name='signup'),
      path('signin/', login.LoginView.as_view(), name='signin'),
      path('logout/', logout.LogoutView.as_view(), name='logout'),
  
      path('account/', settings.SettingView.as_view(), name='account'),
      path('account/avatar/', settings.SetAvatarView.as_view(), name='set-avatar'),
      path('account/name/', settings.SetNameView.as_view(), name='set-name'),
      path('account/biography/', settings.SetBiographyView.as_view(), name='set-biography'),
      path('account/birthday', settings.SetBirthdayView.as_view(), name='set-birthday'),
      path('account/gender/', settings.SetGenderView.as_view(), name='set-gender'),
      path('account/password/', settings.SetPasswordView.as_view(), name='set-password'),
      path('account/dark-theme/', settings.SetDarkView.as_view(), name='set-dark-mode'),
      path('account/color/', settings.SetColorView.as_view(), name='set-color'),
  
      path('u/&lt;int:id&gt;/', profile.ProfileView.as_view(), name='profile'),
  ]
  </code></pre>