title: Django 2: Multiple slugs in url
body: <p>I am currently following a django tutorial by <a href="https://www.youtube.com/watch?v=NqHX4eF2tw8" rel="nofollow noreferrer">sentdex</a>. The tutorial is making a clone of <a href="https://pythonprogramming.net/" rel="nofollow noreferrer">https://pythonprogramming.net/</a>. In the tutorial he uses only one slug in the url, but I think its more convenient to have multiple slugs beacause the urls will be more organized. For example, a link to a tutorial on pythonprogramming.net looks like this: <a href="https://pythonprogramming.net/build-supercomputer-raspberry-pi/" rel="nofollow noreferrer">https://pythonprogramming.net/build-supercomputer-raspberry-pi/</a>. What i want it to look like on my project is <code>mydomain.com/data-analsyis/build-supercomputer/1/</code>. The url would be <code>domain/category/series/episode/</code>, instead of <code>domain/episode/</code>.</p>
  
  <pre><code># urls.py
  from django.urls import path
  from . import views
  
  app_name = "main"
  
  urlpatterns = [
      path('', views.homepage, name="homepage"),  # View categories
      path("register/", views.register, name="register"),
      path("logout/", views.logout_request, name="logout"),
      path("login/", views.login_request, name="login"),
      path("&lt;slug:series_slug&gt;/", views.slugs, name="series_blocks"),  # Views all the series in that category
      path("&lt;slug:series_slug&gt;/&lt;slug:tutorial_slug&gt;/", views.slugs, name="tutorial_blocks"),  # View all tutorials in series
      path("&lt;slug:series_slug&gt;/&lt;slug:tutorial_slug&gt;/&lt;int:id&gt;/", views.slugs, name="tutorial_blocks"),  # View spesific tutorial nr.
  ]
  </code></pre>
  
  <p><strong>Note:</strong> I think it's better to have 3 different functions than the <code>views.slug</code></p>
  
  <pre><code># Models.py
  from django.db import models
  from datetime import datetime
  
  
  class TutorialCategory(models.Model):
      category = models.CharField(max_length=100)
      summary = models.CharField(max_length=200)
      slug = models.CharField(max_length=100)
  
      class Meta:
          verbose_name_plural = "Kategorier"
  
      def __str__(self):
          return self.category
  
  
  class TutorialSeries(models.Model):
      series = models.CharField(max_length=200)
      category = models.ForeignKey(TutorialCategory, default=1, verbose_name="Kategori", on_delete=models.SET_DEFAULT)
      summary = models.CharField(max_length=200)
      slug = models.CharField(max_length=100)  # Not from tutorial, but this is the tutorial slug
  
      class Meta:
          verbose_name_plural = "Serier"
  
      def __str__(self):
          return self.series
  
  
  class Tutorial(models.Model):
      title = models.CharField(max_length=200)
      content = models.TextField()
      published = models.DateTimeField("date published", default=datetime.now())
      series = models.ForeignKey(TutorialSeries, default=1, verbose_name="Serie", on_delete=models.SET_DEFAULT)
      id = models.AutoField(primary_key=True)  # This was originally a slug, but now it's the episode number
  
      def __str__(self):
          return self.title
  </code></pre>
  
  <p>.</p>
  
  <pre><code># Views.py
  def slugs(request, series_slug):
      categories = [c.slug for c in TutorialCategory.objects.all()]
      if series_slug in categories:
          match_series = TutorialSeries.objects.filter(category__slug=series_slug)
          series_urls = {}
          for m in match_series.all():
              part_one = Tutorial.objects.filter(series__series=m.series).earliest("published")
              series_urls[m] = part_one.id
          return render(request, "main/category.html", {"part_ones": series_urls})
  
      tutorials = [t.slug for t in Tutorial.objects.all()]
      if series_slug in tutorials:
          this_tutorial = Tutorial.objects.get(series_slug=series_slug)
          return render(request, "main/tutorial.html", {"tutorial": this_tutorial})
  </code></pre>
  
  <p>The problem I originally had was all the <code>tutorials</code> showed up, not only those from the <code>series</code>. To show only the <code>series</code> worked fine.
  But now, after trying to fix this, I don't really know what to do. I have change the <code>views.py</code> a lot, but now it's the original(from sendtex), and changed the tutorial slug to an Id and giving Tutorial series an slug. </p>
  
  <p>How can I get <code>views.py</code> to only show <code>tutorials</code> in specific <code>series</code>, ect. and have multiple slugs in url? </p>