title: NoReverseMatch - Reverse for 'detail' with arguments and keyword arguments {} not found
body: <p>for some reason I cannot seem to solve this bug. I am using Django 1.5</p>
  
  <p>The actual error I get is</p>
  
  <pre><code>Reverse for 'detail' with arguments '()' and keyword arguments '{u'slug': u'third-post'}' not found.
  </code></pre>
  
  <p>In my projest dir I have this urls.py</p>
  
  <pre><code>from django.conf.urls import patterns, include, url
  
  # Uncomment the next two lines to enable the admin:
  from django.contrib import admin
  admin.autodiscover()
  
  urlpatterns = patterns('',
      # Examples:
      # url(r'^$', 'blog.views.home', name='home'),
      # url(r'^blog/', include('blog.foo.urls')),
  
      # Uncomment the admin/doc line below to enable admin documentation:
      url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
  
      # Uncomment the next line to enable the admin:
      url(r'^admin/', include(admin.site.urls)),
  
      #include the blogapp url
      url(r'', include('blogapp.urls', namespace='blog')),
  )
  </code></pre>
  
  <p>The urls.py in my app folder looks like this</p>
  
  <pre><code>urlpatterns = patterns ('',
  
      url(r'^$', 
              ListView.as_view(
                      queryset = Post.objects.order_by('-pub_date')[:5],
                      context_object_name = 'latest_posts',
                      template_name = 'blogapp/default.html'),
              name = 'index'
          ),
  
      url(r'^post/(?P&lt;slug&gt;\w+)/$',
              PostDetailView.as_view(),
              name = 'detail'
          ),
  )
  </code></pre>
  
  <p>My post detail view looks like this</p>
  
  <pre><code>class PostDetailView(DetailView):
  
      template_name = 'blogapp/post/detail.html'
  
      def get_object(self):
          return get_object_or_404(Post, slug__iexact = self.kwargs['slug'])
  </code></pre>
  
  <p>I have this in my html</p>
  
  <pre><code>{% for p in latest_posts %}
        &lt;li&gt;&lt;a href="{% url 'blog:detail' p.slug %}"&gt;{{p.title}}&lt;/a&gt;&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <p>I can open my shell and I get a url back</p>
  
  <pre><code>&gt;&gt;&gt; from django.core.urlresolvers import reverse
  &gt;&gt;&gt; reverse('blog:detail', kwargs={'slug':'test'})
  '/post/test/'
  </code></pre>
  
  <p>The weird thing is in my html this line works</p>
  
  <pre><code>&lt;li&gt;&lt;a href="{% url 'blog:detail' p.id %}"&gt;{{p.title}}&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>why would p.id work and not p.slug?</p>
  
  <p>Here is the traceback</p>
  
  <pre><code>Environment:
  
  
  Request Method: GET
  Request URL: http://127.0.0.1:8000/
  
  Django Version: 1.5
  Python Version: 2.7.2
  Installed Applications:
  ('django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.sites',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'django.contrib.admin',
   'django.contrib.admindocs',
   'south',
   'blogapp')
  Installed Middleware:
  ('django.middleware.common.CommonMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware')
  
  
  Template error:
  In template .../Development/Python/Django/dev/blog/blogapp/templates/blogapp/default.html, error at line 11
     Reverse for 'detail' with arguments '()' and keyword arguments '{u'slug': u'third-post'}' not found.
     1 : {% extends "blogapp/base.html" %}
  
  
     2 : 
  
  
     3 : {% block title %}Blog Posts{% endblock %}
  
  
     4 : 
  
  
     5 : {% block body %}
  
  
     6 : 
  
  
     7 :     {% if latest_posts %}
  
  
     8 :         &lt;p&gt;Latest 5 blog posts&lt;/p&gt;
  
  
     9 :             &lt;ul&gt;
  
  
     10 :                 {% for p in latest_posts %}
  
  
     11 :                     &lt;li&gt;&lt;a href=" {% url 'blog:detail' slug=p.slug %} "&gt;{{p.title}}&lt;/a&gt;&lt;/li&gt;
  
  
     12 :                 {% endfor %}
  
  
     13 :             &lt;/ul&gt;
  
  
     14 :     {% else %}
  
  
     15 :         &lt;p&gt;No blog posts published.&lt;/p&gt;
  
  
     16 :     {% endif %}
  
  
     17 : 
  
  
     18 : {% endblock %}
  
  
     19 : 
  
  
     20 : 
  
  Traceback:
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
    140.                     response = response.render()
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/response.py" in render
    105.             self.content = self.rendered_content
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/response.py" in rendered_content
    82.         content = template.render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/base.py" in render
    140.             return self._render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/base.py" in _render
    134.         return self.nodelist.render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/base.py" in render
    830.                 bit = self.render_node(node, context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/debug.py" in render_node
    74.             return node.render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/loader_tags.py" in render
    124.         return compiled_parent._render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/base.py" in _render
    134.         return self.nodelist.render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/base.py" in render
    830.                 bit = self.render_node(node, context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/debug.py" in render_node
    74.             return node.render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/loader_tags.py" in render
    63.             result = block.nodelist.render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/base.py" in render
    830.                 bit = self.render_node(node, context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/debug.py" in render_node
    74.             return node.render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/defaulttags.py" in render
    284.                 return nodelist.render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/base.py" in render
    830.                 bit = self.render_node(node, context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/debug.py" in render_node
    74.             return node.render(context)
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/defaulttags.py" in render
    188.                         nodelist.append(node.render(context))
  File ".../.virtualenvs/env1/lib/python2.7/site-packages/django/template/defaulttags.py" in render
    424.                         raise e
  
  Exception Type: NoReverseMatch at /
  Exception Value: Reverse for 'detail' with arguments '()' and keyword arguments '{u'slug': u'third-post'}' not found.
  </code></pre>