title: Django 2.0 - Not a valid view function or pattern name (Customizing Auth views)
body: <p>I´m working on a course exercise and I'm stuck for a few hours and I'm not sure what is causing the app to break, next, you will find the files involved and perhaps you can find out the solution. Thanks for your help!</p>
  
  <p><a href="https://i.stack.imgur.com/Hb3gD.png" rel="noreferrer">Project structure</a></p>
  
  <p>This error is being thrown when I log in:</p>
  
  <pre><code>Internal Server Error: /account/login/
  
  ...
  
  
      django.urls.exceptions.NoReverseMatch: Reverse for 'dashboard' not found. 'dashboard' is not a valid view function or pattern name.
      [04/Apr/2018 17:12:15] "POST /account/login/ HTTP/1.1" 500 151978
  </code></pre>
  
  <p><strong>At the end of the <em>settings.py</em> file</strong></p>
  
  <pre><code>from django.urls import reverse_lazy
  
  LOGIN_REDIRECT_URL = reverse_lazy('dashboard')
  LOGIN_URL = reverse_lazy('login')
  LOGOUT_REDIRECT_URL = reverse_lazy('logout')
  </code></pre>
  
  <p><strong>The <em>urls.py</em> file</strong></p>
  
  <pre><code>from django.contrib.auth import views as auth_views
  from django.urls import path
  from . import views
  
  app_name = 'account'
  
  urlpatterns = [
      # path('login/', views.user_login, name='login'),
      path('', views.dashboard, name='dashboard'),
  
      # login / logout urls
      path('login/', auth_views.LoginView.as_view(template_name='registration/login.html'), name='login'),
      path('logout/', auth_views.LogoutView.as_view(template_name='registration/logged_out.html'), name='logout'),
      path('logout-then-login/', auth_views.logout_then_login, name='logout_then_login'),
  ]
  </code></pre>
  
  <p><strong>The <em>views.py</em> file</strong></p>
  
  <pre><code>from django.contrib.auth import authenticate, login
  from django.contrib.auth.decorators import login_required
  from django.http import HttpResponse
  from django.shortcuts import render
  
  
  @login_required
  def dashboard(request):
      return render(request, 'account/dashboard.html', {'section': 'dashboard'})
  </code></pre>
  
  <p><strong>The <em>base.html</em> template</strong></p>
  
  <pre><code>{% load staticfiles %}
  &lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport"
            content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="ie=edge"&gt;
      &lt;title&gt;{% block title %}{% endblock %}&lt;/title&gt;
      &lt;link rel="stylesheet" href="{% static "css/base.css" %}"&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="header"&gt;
          &lt;span class="logo"&gt;Bookmarks&lt;/span&gt;
          {% if request.user.is_authenticated %}
              &lt;ul class="menu"&gt;
                  &lt;li&gt; {% if section == "dashboard" %}class="selected"{% endif %}&gt;&lt;a href="{% url "account:dashboard" %}"&gt;My dashboard&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt; {% if section == "images" %}class="selected"{% endif %}&lt;a href="#"&gt;Images&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt; {% if section == "people" %}class="selected"{% endif %}&lt;a href="#"&gt;People&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          {% endif %}
  
          &lt;span class="user"&gt;
              {% if request.user.is_authenticated %}
                  Hello {{ request.user.first_name }}, &lt;a href="{% url "account:logout %}"&gt;Logout&lt;/a&gt;
              {% else %}
                  &lt;a href="{% url "account:dashboard" %}"&gt;&lt;/a&gt;
              {% endif %}
          &lt;/span&gt;
      &lt;/div&gt;
  
      &lt;div id="content"&gt;
          {% block content %}
          {% endblock %}
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I appreciate your help. Thanks a lot!</p>