code: def lookup_object(model, object_id, slug, slug_field):
      
      lookup_kwargs = {}
      if object_id:
          lookup_kwargs['%s__exact' % model._meta.pk.name] = object_id
      elif slug and slug_field:
          lookup_kwargs['%s__exact' % slug_field] = slug
      else:
          raise GenericViewError(
              "Generic view must be called with either an object_id or a"
              " slug/slug_field.")
      try:
          return model.objects.get(**lookup_kwargs)
      except ObjectDoesNotExist:
          raise Http404("No %s found for %s"
                        % (model._meta.verbose_name, lookup_kwargs))
docs: Return the ``model`` object with the passed ``object_id``.  If
      ``object_id`` is None, then return the object whose ``slug_field``
      equals the passed ``slug``.  If ``slug`` and ``slug_field`` are not passed,
      then raise Http404 exception.