title: Trying to create a home page with a login form, but getting 'NameError: name 'url' is not defined'
body: <p>I'm relatively new to django and trying to create a home page that has a login form on it, consisting of username and pw bars. I was trying to recreate what I saw here in my own project:</p>
  
  <p><a href="https://stackoverflow.com/questions/20208562/homepage-login-form-django">homepage login form Django</a></p>
  
  <p>but I keep getting back
  NameError: name 'url' is not defined. I am pretty lost on what is causing this. I was initially writing into the project level urls.py but then moved to the app level (accounts) urls.py because that makes sense to me...but I'm not confident about this. </p>
  
  <p>Here are my files:</p>
  
  <pre><code>project
      ├── manage.py
      ├── db.sqlite3
      ├── templates
      ├── accounts
      |     ├──migrations
      |     ├──_pycache_
      |     ├──admin.py
      |     ├──apps.py
      |     ├──models.py
      |     ├──_init__.py
      |     ├──urls.py
      |     ├──tests.py
      |     └──views.py
      └── project
            ├── settings.py
            ├── urls.py
            └── wsgi.py
  </code></pre>
  
  <p>project/settings.py</p>
  
  <pre><code>from django.urls import reverse_lazy
  import os
  ...
  SITE_ID = 1
  
  LOGIN_URL = reverse_lazy('login')
  LOGIN_REDIRECT__URL = reverse_lazy('home')
  LOGOUT_REDIRECT__URL = '/'
      enter code here
  </code></pre>
  
  <p>project/urls.py</p>
  
  <pre><code>from django.contrib import admin
  from django.urls import path, include
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('accounts/', include('django.contrib.auth.urls')),
      path('accounts/', include('accounts.urls')),
      path('accounts/', include('allauth.urls')),
      path('', include('posts.urls')),
  ]
  </code></pre>
  
  <p>accounts/urls.py</p>
  
  <pre><code>from django.urls import path
  from . import views
  
  urlpatterns = [
      path('signup/', views.SignUpView.as_view(), name='signup'),
      url(r'^accounts/', HomeView.as_view(template_name='../templates/home.html', name='home')),
      url(r'^accounts/login/$', 'django.contrib.auth.views.login', name='login'),
      url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', name='logout'),
  ]
  </code></pre>
  
  <p>accounts/views.py</p>
  
  <pre><code>from django.shortcuts import render
  from django.contrib.auth.forms import UserCreationForm
  from django.urls import reverse_lazy
  from django.views import generic
  from django.views.generic.base import TemplateView
  from django.contrib.auth.decorators import login_required
  from django.utils.decorators import method_decorator
  
  class SignUpView(generic.CreateView):
      form_class = UserCreationForm
      success_url = reverse_lazy('login')
      template_name = 'signup.html'
  
  class HomeView(TemplateView):
      @method_decorator(login_required)
      def dispatch(self, *args, **kwargs):
          return super(HomeView, self).dispatch(*args, **kwargs)
  </code></pre>
  
  <p>templates/home.html</p>
  
  <pre><code>    &lt;!--user checks--&gt;
      {% if user.is_authenticated %}
      &lt;div class = "greeting"&gt;
          Hi {{ user.username }}!
          &lt;a href="{% url 'logout' %}"&gt;logout&lt;/a&gt;
      &lt;/div&gt;
      {% else %}
      &lt;div class = "register"&gt;
          &lt;a href="{% url 'signup' %}"&gt;sign up!&lt;/a&gt;
      &lt;/div&gt;
      &lt;a href="{% url 'login' %}"&gt;login&lt;/a&gt;
      &lt;form method = "post" action = "{% url 'django.contrib.auth.views.login' %}"&gt;
      {% csrf_token %}
  
      &lt;!--username bar--&gt;
      &lt;div class="container-2"&gt;
          {{ form.username.label_tag }}
          {{ form.username }}
      &lt;/div&gt;
  
      &lt;!--pw bar--&gt;
      &lt;div class="container-3"&gt;
          {{ form.password.label_tag }}
          {{ form.password }}
      &lt;/div&gt;
      &lt;input type="submit" value="login" /&gt;
      &lt;input type="hidden" name="next" value="{{ next }}" /&gt;
      &lt;/form&gt;
  
  
      {% endif %}
  </code></pre>