title: Creating a Path Based on Multiple SlugFields in Django
body: <p>I have a Django project based around creating tournaments and nesting specific objects within them. For instance, every tournament has multiple committees. When someone creates a tournament, I allow them to create a link with a <code>SlugField</code>. My code (so far) is as follows:</p>
  
  <p><em>models.py</em></p>
  
  <pre class="lang-py prettyprint-override"><code>from django.db import models
  from django.utils.text import slugify
  
  class Tournament(models.Model):
      name = models.CharField(max_length=50)
      slug = models.SlugField(max_length=50, unique=True)
  
      def _get_unique_slug(self):
          '''
          In this method a unique slug is created
          '''
          slug = slugify(self.name)
          unique_slug = slug
          num = 1
          while Tournament.objects.filter(slug=unique_slug).exists():
              unique_slug = '{}-{}'.format(slug, num)
              num += 1
          return unique_slug
  
      def save(self, *args, **kwargs):
          if not self.slug:
              self.slug = self._get_unique_slug()
          super().save(*args, **kwargs)
  
  class Committee(models.Model):
      name = models.CharField(max_length=100)
      belongsTo = models.ForeignKey(Tournament, blank=True, null=True)
      slug = models.SlugField(max_length=50, unique=True)
  
      def _get_unique_slug(self):
          '''
          In this method a unique slug is created
          '''
          slug = slugify(self.name)
          unique_slug = slug
          num = 1
          while Committee.objects.filter(slug=unique_slug).exists():
              unique_slug = '{}-{}'.format(slug, num)
              num += 1
          return unique_slug
  
      def save(self, *args, **kwargs):
          if not self.slug:
              self.slug = self._get_unique_slug()
          super().save(*args, **kwargs)
  </code></pre>
  
  <p><em>views.py</em>
  </p>
  
  <pre><code>from django.shortcuts import render, get_object_or_404
  from .models import Tournament, Committee
  
  def tournament_detail_view(request, slug):
      tournament = get_object_or_404(Tournament, slug=slug)    
      return render(request, 'tournament/detail.html', {'tournament': tournament})
  
  def committee_detail_view(request, slug): 
      committee = get_object_or_404(Committee, slug=slug)    
      return render(request, 'committee/detail.html', {'committee': committee})
  </code></pre>
  
  <p><em>urls.py</em></p>
  
  <pre class="lang-py prettyprint-override"><code>from . import views
  from django.urls import path
  
  app_name = 'tournament'
  urlpatterns = [
      path('&lt;slug:slug&gt;/', views.tournament_detail_view),
  ]
  </code></pre>
  
  <p>My question concerns <code>urls.py</code>. If a user creates a tournament called 'Zavala', they can currently access the website at <code>example.com/zavala</code>. However, if they create a committee named 'Cayde' under said tournament, there is no way for them to access the committee at <code>example.com/zavala/cayde</code>. The issue is that both of the sub-urls are slugs, and I'm not sure if Django can work with this. Is there a way to create a path that allows the user to go to the committee? I thought something along the lines of creating a function to test whether or not the tournament existed, but wasn't sure exactly how. Any tips? All I need is a working solution.</p>