title: TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names() - Django 2.1
body: <p>I´m trying to log in a user without password using Django, until now I have created this:</p>
  <p>Nopassword.py</p>
  <pre><code>class PasswordlessAuthBackend(ModelBackend):
     
      def authenticate(self, username=None):
          try:
              return User.objects.get(username=username)
          except User.DoesNotExist:
              return None
  
      def get_user(self, user_id):
          try:
              return User.objects.get(pk=user_id)
          except User.DoesNotExist:
              return None
  </code></pre>
  <p>views.py</p>
  <pre><code>from .Nopassword import PasswordlessAuthBackend
  user = User()
  p = PasswordlessAuthBackend()
  user.username = p.get_user(user_id=None)
  user = p.authenticate(username=user.username)
  
  
  def home(request):
      login(request, user)
  </code></pre>
  <p>The problem is that when I run the webapp, I´m getting this error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/core/handlers/exception.py&quot;, line 35, in inner
      response = get_response(request)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/core/handlers/base.py&quot;, line 128, in _get_response
      response = self.process_exception_by_middleware(e, request)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/core/handlers/base.py&quot;, line 126, in _get_response
      response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File &quot;/home/bohosul02/misitio/gfgauth/views.py&quot;, line 29, in home
      login(request, user)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/contrib/auth/views.py&quot;, line 125, in login
      )(request)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/views/generic/base.py&quot;, line 69, in view
      return self.dispatch(request, *args, **kwargs)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/utils/decorators.py&quot;, line 62, in _wrapper
      return bound_func(*args, **kwargs)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/views/decorators/debug.py&quot;, line 76, in sensitive_post_parameters_wrapper
      return view(request, *args, **kwargs)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/utils/decorators.py&quot;, line 58, in bound_func
      return func.__get__(self, type(self))(*args2, **kwargs2)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/utils/decorators.py&quot;, line 62, in _wrapper
      return bound_func(*args, **kwargs)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/utils/decorators.py&quot;, line 142, in _wrapped_view
      response = view_func(request, *args, **kwargs)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/utils/decorators.py&quot;, line 58, in bound_func
      return func.__get__(self, type(self))(*args2, **kwargs2)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/utils/decorators.py&quot;, line 62, in _wrapper
      return bound_func(*args, **kwargs)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/views/decorators/cache.py&quot;, line 44, in _wrapped_view_func
      response = view_func(request, *args, **kwargs)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/utils/decorators.py&quot;, line 58, in bound_func
      return func.__get__(self, type(self))(*args2, **kwargs2)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/contrib/auth/views.py&quot;, line 66, in dispatch
      return super().dispatch(request, *args, **kwargs)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/views/generic/base.py&quot;, line 89, in dispatch
      return handler(request, *args, **kwargs)
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/views/generic/edit.py&quot;, line 133, in get
      return self.render_to_response(self.get_context_data())
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/views/generic/base.py&quot;, line 126, in render_to_response
      template=self.get_template_names(),
    File &quot;/home/bohosul02/.virtualenvs/myproject/lib/python3.6/site-packages/django/views/generic/base.py&quot;, line 139, in get_template_names
      &quot;TemplateResponseMixin requires either a definition of &quot;
  django.core.exceptions.ImproperlyConfigured: TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'
  </code></pre>
  <p>I have searched about information of this error, but I have found that when all people were experiencing this error, it was because they had created a class inside their views.py file.</p>
  <p>How can I solve that?</p>
  <p>Django version: 2.1</p>