Q:

Django error in request/response middleware- TypeError: __init__() takes 1 positional argument but 2 were given

I'm still pretty new to Django and cant seem to get anywhere with this error (I've read through similar posts here with no luck).  Code in urls.py is pasted below:
from django.conf.urls import include, url
from django.contrib import admin
# Add this import
from django.contrib.auth import views
from log.forms import LoginForm

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include(('dashboard.urls', "dashboard"), namespace='dashboard')),
    url(r'^login/$', views. LoginView, {'template_name': 'login.html', 'authentication_form': LoginForm}, name='login'),
    url(r'^logout/$', views. LogoutView, {'next_page': '/'}),
]

Full trace is below:
Internal Server Error: /login/
Traceback (most recent call last):
  File "C:\Python36-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Python36-32\lib\site-packages\django\core\handlers\base.py", line 127, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Python36-32\lib\site-packages\django\core\handlers\base.py", line 125, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
TypeError: __init__() takes 1 positional argument but 2 were given
[21/Aug/2018 00:20:27] "GET /login/?next=/ HTTP/1.1" 500 64213

Any ideas on how to solve this?  Or what could be causing this error? 

A:

In short: you need to use .as_view() to "convert" a class-based view, to a view that can be used in the urls.py. 
The LoginView [Django-doc] and LogoutView [Django-doc] are class-based views, in order to make these callable in the urls.py, you need to use as_view:
from django.conf.urls import include, url
from django.contrib import admin
# Add this import
from django.contrib.auth import views
from log.forms import LoginForm

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include(('dashboard.urls', "dashboard"), namespace='dashboard')),
    url(r'^login/$', views. LoginView.as_view(), {'template_name': 'login.html', 'authentication_form': LoginForm}, name='login'),
    url(r'^logout/$', views. LogoutView.as_view(), {'next_page': '/'}),
]
A class-based view contains such function that acts as a wrapper, and each time initializes a instance.  If you would use LoginView directly, you would call the constructor of the LoginView class.  Although with some extra logic, it would be possible to return a HttpResponse, it is not very elegant (you do not expect a HttpResponse when you construct a LoginView), and furthermore it would make subclassing of views (which is one of the reasons why such class-based views can save a lot of work) very cumbersome.