title: Django can't resolve a url name
body: <p>I'm a newb of Django.</p>
  
  <p>The code doesn't seem to be able to resolve my "login" url, and I require your aid to continue on with my development.</p>
  
  <p>The following is the exception I get:</p>
  
  <pre><code>Environment:
  
  
  Request Method: GET
  Request URL: http://localhost:9999/bz/logout/
  
  Django Version: 1.7
  Python Version: 3.4.1
  Installed Applications:
  ('django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'bz')
  Installed Middleware:
  ('django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.clickjacking.XFrameOptionsMiddleware')
  
  
  Traceback:
  File "D:\Python34\lib\site-packages\django\core\handlers\base.py" in get_response
    111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "D:\dev\python\eli\bz\views.py" in user_logout
    102.     return HttpResponseRedirect(reverse('login'), {'logged_out_success_message': user.username + " logged out successfully"})
  File "D:\Python34\lib\site-packages\django\core\urlresolvers.py" in reverse
    546.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
  File "D:\Python34\lib\site-packages\django\core\urlresolvers.py" in _reverse_with_prefix
    463.                              (lookup_view_s, args, kwargs, len(patterns), patterns))
  
  Exception Type: NoReverseMatch at /bz/logout/
  Exception Value: Reverse for 'login' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
  </code></pre>
  
  <p>This is my urls.py:</p>
  
  <pre><code>from django.conf.urls import patterns, url
  
  from bz import views
  
  urlpatterns = patterns('',
    (r'^$', views.index),
    url(r'^login/$', views.user_login, name='login'),
    (r'^logout/$', views.user_logout),
    (r'^register/$', views.register),
    )
  </code></pre>
  
  <p>And this is the problematic section where the resolution fails:</p>
  
  <pre><code>def user_logout(request):
    user = request.user
    if user.is_authenticated:
      logout(request)
      return HttpResponseRedirect(reverse('login'), {'logged_out_success_message': user.username + " logged out successfully"})
    else:
      return render(request, 'bz/index.html', {})
  </code></pre>
  
  <p>Your help would be appreciated.</p>
  
  <p>Thank you.</p>