title: How do i use slug urls correctly in Django?
body: <p><strong>Hello, i'm new to Django, and I'm trying to build a web site.</strong>
  <strong>at the admin page <a href="http://127.0.0.1:8000/admin/posts/post/" rel="nofollow noreferrer">http://127.0.0.1:8000/admin/posts/post/</a> i added two posts, eatch one have a slug, the **first slug is first and the second one is second
  the problem is when i try to reach <a href="http://127.0.0.1:8000/posts/first" rel="nofollow noreferrer">http://127.0.0.1:8000/posts/first</a> or <a href="http://127.0.0.1:8000/posts/second" rel="nofollow noreferrer">http://127.0.0.1:8000/posts/second</a> it gives me a 404 error</strong> and it tells me** </p>
  
  <blockquote>
    <p>Using the URLconf defined in custom.urls, Django tried these URL
    patterns, in this order:</p>
  
  <pre><code>admin/
  posts/ [name='posts_list']
  &lt;slug&gt;
  </code></pre>
    
    <p>The current path, posts/first, didn't match any of these.</p>
  </blockquote>
  
  <p><strong>this is models.py</strong></p>
  
  <pre><code>from django.db import models
  from django.conf import settings
  Create your models here.
  
  User = settings.AUTH_USER_MODEL
  
  class Author(models.Model):
      user = models.ForeignKey(User, on_delete=models.CASCADE)
      email = models.EmailField()
      phone_num = models.IntegerField(("Phone number"))
  
      def __str__(self):
         return self.user.username
  
  class Post(models.Model):
      title = models.CharField(max_length=120)
      description = models.TextField()
      slug = models.SlugField()
      image = models.ImageField()
      author = models.OneToOneField(Author, on_delete=models.CASCADE)
  
  
      def __str__(self):
          return self.title
  </code></pre>
  
  <p><strong>this is views.py</strong></p>
  
  <pre><code>from django.shortcuts import render, get_object_or_404
  from .models import Post
  # Create your views here.
  
  
  def posts_list(request):
      all_posts = Post.objects.all()
      return render(request, 
                    "posts/posts_list.html", 
                    context = {"all_posts": all_posts})
  
  
  def posts_detail(request, slug):
      unique_slug = get_object_or_404(Post, slug = slug)
  
      return render(request, "posts/posts_detail.html", {"post": unique_slug})
  </code></pre>
  
  <p><strong>this is the urls.py</strong></p>
  
  <pre><code>from django.contrib import admin
  from django.urls import path
  from posts.views import posts_list, posts_detail
  urlpatterns = [
          path('admin/', admin.site.urls),
          path("posts/", posts_list, name = "posts_list"),
          path("&lt;slug&gt;", posts_detail), #, name = "unique_slug"
      ]
  </code></pre>
  
  <p><strong>and this is those are the templates:</strong>
  <strong>posts_list.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;
          &lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          {{ all_posts }}
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>post_detail.html</strong>    </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;
          &lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          {{ post }}
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>