title: Django - How to create a slug url that works?
body: <p>I'm a newbie and I've been battling with an error while trying to display the detail page of a post. I've checked other answers relating to this question but the solutions still don't work for me.</p>
  
  <p>This is the error I'm getting:</p>
  
  <pre><code>Reverse for 'blog_post' with no arguments not found. 1 pattern(s) tried: ['blog\\/post/(?P&lt;slug&gt;[-\\w]+)/$']
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/gwcQM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gwcQM.png" alt="Django error page"></a></p>
  
  <p>This is my model:</p>
  
  <pre><code>class Post(models.Model):
      STATUS_CHOICES = (
      ('draft', 'Draft'),
      ('published', 'Published'),
  )
  
      title = models.CharField(max_length=200)
      slug = models.SlugField(max_length=200, unique_for_date='publish')
      author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
      body = models.TextField()
      publish = models.DateTimeField(default=timezone.now)
      created = models.DateTimeField(auto_now_add=True)
      updated = models.DateTimeField(auto_now=True)
      status = models.CharField(max_length=10, choices=STATUS_CHOICES, 
         default='draft')
  
     class Meta:
       ordering = ('-publish',)
  
     def __str__(self):
       return self.title
  
     def get_absolute_url(self):
        return reverse('blog:post', args=[str(self.slug)])
  </code></pre>
  
  <p>View functions:</p>
  
  <pre><code>class BlogHomePageView(ListView):
    model = Post
    template_name = 'blog/index.html'
  
  class PostDetailView(DetailView):
    model = Post
    template_name = 'blog/post.html'
    slug_url_kwarg = 'slug'
    query_pk_and_slug = True
  </code></pre>
  
  <p>Urlpatterns:</p>
  
  <pre><code>path('', BlogHomePageView.as_view(), name='blog_home'),
  re_path(r'post/(?P&lt;slug&gt;[-\w]+)/$', PostDetailView.as_view(), name='blog_post'),
  </code></pre>
  
  <p>base.html</p>
  
  <pre><code>&lt;!-- Navigation --&gt;
  &lt;nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav"&gt;
      &lt;div class="container"&gt;
          &lt;a class="navbar-brand" href="index.html"&gt;Toluwalemi&lt;/a&gt;
          &lt;button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
                  data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false"
                  aria-label="Toggle navigation"&gt;
              Menu
              &lt;i class="fas fa-bars"&gt;&lt;/i&gt;
          &lt;/button&gt;
          &lt;div class="collapse navbar-collapse" id="navbarResponsive"&gt;
              &lt;ul class="navbar-nav ml-auto"&gt;
                  &lt;li class="nav-item"&gt;
                      &lt;a class="nav-link" href="{% url 'blog_home' %}"&gt;Home&lt;/a&gt;
                  &lt;/li&gt;
                  &lt;li class="nav-item"&gt;
                      &lt;a class="nav-link" href="{% url 'blog_about' %}"&gt;About&lt;/a&gt;
                  &lt;/li&gt;
                  &lt;li class="nav-item"&gt;
                      &lt;a class="nav-link" href="{% url 'blog_post' %}"&gt;Sample Post&lt;/a&gt;
                  &lt;/li&gt;
                  &lt;li class="nav-item"&gt;
                      &lt;a class="nav-link" href="{% url 'blog_contact' %}"&gt;Contact&lt;/a&gt;
                  &lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>detail page:</p>
  
  <pre><code>{% extends 'blog/base.html' %}
  
  {% block title %}Post{% endblock %}
  
  
  &lt;!-- Page Header --&gt;
  {% block page_header %}
      &lt;div class="post-heading"&gt;
          &lt;h1&gt;{{ post.title }}&lt;/h1&gt;
          &lt;h2 class="subheading"&gt;Problems look mighty small from 150 miles up&lt;/h2&gt;
          &lt;span class="meta"&gt;Posted by
                &lt;a href="#"&gt;{{ post.author }}&lt;/a&gt;
                on {{ post.publish }}&lt;/span&gt;
      &lt;/div&gt;
  {% endblock %}
  
  &lt;!-- Post Content --&gt;
  &lt;article&gt;
      {% block content %}
          &lt;p&gt;{{ post.body }}&lt;/p&gt;
  </code></pre>
  
  <p>list page:</p>
  
  <pre><code>{% extends 'blog/base.html' %}
  
  {% block title %}Home{% endblock %}
  
  &lt;!-- Page Header --&gt;
  {% block page_header %}
      &lt;div class="site-heading"&gt;
          &lt;h1&gt;Toluwalemi's Blog&lt;/h1&gt;
          &lt;span class="subheading"&gt;Official Blog&lt;/span&gt;
      &lt;/div&gt;
  {% endblock %}
  
  &lt;!-- Main Content --&gt;
  {% block content %}
      {% for post in object_list %}
          &lt;div class="post-preview"&gt;
              &lt;a href="{{ post.get_absolute_url }}"&gt;
                  &lt;h2 class="post-title"&gt;
                      {{ post.title }}
                  &lt;/h2&gt;
  </code></pre>