title: using get_context_data() method to retrieve a list of dependant objects within DetailView Django
body: <p>I am creating a simple car dealership application in Django 3 whereby when goes to a detail page of a category it should list all cars that belong in that category , so in my case car objects are dependent objects of their respective category . I have tried to implement this using get_context_data() method and referencing the two respective models within the DetailView here is my code </p>
  
  <p>models.py category</p>
  
  <pre><code>from django.db import models
  
  from django.urls import reverse
  
  # Create your models here.
  
  
  class Category(models.Model):
      name = models.CharField(null=False, blank=False, max_length=20)
      description = models.TextField(null=False, blank=False, max_length=120)
      image = models.ImageField(upload_to='images/')
  
      def __str__(self):
          return self.name
  
      def get_absolute_url(self):
          return reverse('category_detail', args=[str(self.id)])
  
  </code></pre>
  
  <p>models.py cars</p>
  
  <pre><code>from django.db import models
  
  from django.urls import reverse
  
  from categories.models import Category
  
  # Create your models here.
  
  
  class Car(models.Model):
      image = models.ImageField(upload_to='images/cars/')
      make = models.CharField(null=False, blank=False, max_length=30)
      model = models.CharField(null=False, blank=False, max_length=30)
      year = models.IntegerField(null=False, blank=False)
      transmission = models.CharField(null=False, blank=False, max_length=30)
      category = models.ForeignKey(Category, on_delete=models.CASCADE)
  
      def __str__(self):
          return self.model
  
      def get_absolute_url(self):
          return reverse('car_detail', args=[str(self.id)])
  
  </code></pre>
  
  <p>views categories</p>
  
  <pre><code>from django.shortcuts import render
  
  from django.views.generic import ListView, DetailView
  
  from .models import Category
  from cars.models import Car
  # Create your views here.
  
  
  class CategoryList(ListView):
      model = Category
      template_name = 'category_list.html'
  
  
  class CategoryDetailView(DetailView):
      model = Category
      template_name = 'category_detail.html'
  
      def get_context_data(self, *args, **kwargs):
          context = super(CategoryDetailView, self).get_context_data(
              *args, **kwargs)
          context['category_cars'] = Car.objects.filter(
              category=self.request.name)
          return context
  
  </code></pre>
  
  <p>urls categories</p>
  
  <pre><code>from django.urls import path
  
  from .views import CategoryList, CategoryDetailView
  
  urlpatterns = [
      path('categories/', CategoryList.as_view(), name='categories'),
      path('categories/&lt;int:pk&gt;/', CategoryDetailView.as_view(), name='category_detail')
  ]
  
  </code></pre>
  
  <p>so using my above implementation results into an error </p>
  
  <p><a href="https://i.stack.imgur.com/phETh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/phETh.png" alt="enter image description here"></a></p>
  
  <p>any suggestions so as to achieve my desired functionality?</p>