title: django url without pk
body: <p>I have been trying for too long now to get my urls working with my simple models and view. There is something I am definitely not understanding.</p>
  
  <p>I wish to create a url similar to:
  <code>.../department/team</code>,
  where I do not use the PK of department object but the name instead.</p>
  
  <p>My model looks like:</p>
  
  <pre><code>class Department(models.Model):
      name = models.CharField(max_length=50, blank=True, null=True)
      def __str__(self):
          return 'Department: ' + self.name
  
  class Hold(models.Model):
      name = models.CharField(max_length=50, blank=True, null=True)
      department = models.ForeignKey(Department, on_delete=models.CASCADE)
  </code></pre>
  
  <p>my view looks like (<strong>UPDATED</strong>):</p>
  
  <pre><code>class IndexView(generic.ListView):
     template_name = 'index.html'
     context_object_name = 'departments_list'
  
     def get_queryset(self):
         return Department.objects.all()
  
  class DepartmentView(generic.DetailView):
      model = Department
      template_name="depdetail.html"
      slug_field = "name"
      slug_url_kwarg = "name"
  </code></pre>
  
  <p>my url looks the following: <strong>UPDATED</strong></p>
  
  <pre><code>urlpatterns = [
      path('', views.IndexView.as_view(), name='index'),
      path('&lt;name&gt;', views.DepartmentView.as_view(), name='depdetail')
   ]
  </code></pre>
  
  <p>and finally my html:</p>
  
  <pre><code>&lt;h1&gt; Hello there {{ object.name }} student&lt;/h1&gt; &lt;/br&gt;
  &lt;b&gt; Choose your team:&lt;b&gt; &lt;/br&gt;
  </code></pre>
  
  <p>however i keep getting <code>page not found</code> or <code>must be slug or pk</code>..
  I hope someone can help me out so I can wrap my head around this.</p>
  
  <p><strong>UPDATED</strong>
  It works now :) Thank you for the replies.</p>