title: Django View with two Slugs
body: <p>How to write a Django View with two slugs?</p>
  
  <p><strong>Each slug is from different Models.</strong></p>
  
  <p>I want to get www.example.com/category/slug1/slug2</p>
  
  <p>Please provide an example code.</p>
  
  <p>Views.py</p>
  
  <pre><code>class SubjectDetailView(generic.DetailView, SingleObjectMixin):
      model           = Programmesearch
      template_name   = 'mnsdirectory/subject_detail.html'
      slug_field      = 'subjectslug'
      slug_url_kwarg  = 'subjectslug'
  </code></pre>
  
  <p>Urls.py</p>
  
  <pre><code>app_name    = 'mnsdirectory'
  urlpatterns = [
      path('', views.IndexView.as_view(), name='index'), #views.indexSubjectDetailView(View)
      path('study/&lt;slug:subjectslug&gt;/', views.SubjectDetailView.as_view(), name='subject-detail'),
      path('study-abroad/&lt;slug:studylevelslug&gt;/', views.StudylevelDetailView.as_view(), name='studylevel-list'),
      ]
  </code></pre>
  
  <p>Models.py:</p>
  
  <pre><code>class Programmesearch(models.Model):
      full_subject_name   =   models.CharField(max_length=100, blank=False, null=False)
      subjectslug         =   models.SlugField(unique=True, editable=False, max_length=100)
  
  class StudyLevel(models.Model):
      study_level     = models.CharField(max_length=100, blank=False, null=False)
      studylevelslug  = models.SlugField(unique=True, editable=False, max_length=100)
  </code></pre>