code: def get_object_from_list_detail_view(request, *args, **kwargs):
      
      queryset = kwargs['queryset']
      object_id = kwargs.get('object_id', None)
      slug = kwargs.get('slug', None)
      slug_field = kwargs.get('slug_field', 'slug')
      if object_id:
          obj = get_object_or_404(queryset, pk=object_id)
      elif slug and slug_field:
          obj = get_object_or_404(queryset, **{slug_field: slug})
      else:
          raise AttributeError(
                  "Generic detail view must be called with either an "
                  "object_id or a slug/slug_field."
              )
      return obj
docs: Get object from generic list_detail.detail view
  
      Parameters
      ----------
      request : instance
          An instance of HttpRequest
  
      Returns
      -------
      instance
          An instance of model object or None