'Return the object the view is displaying.
Require `self.queryset` and a `pk` or `slug` argument in the URLconf.
Subclasses can override this to return any object.'

def get_object(self, queryset=None):

    if (queryset is None):
        queryset = self.get_queryset()
    pk = self.kwargs.get(self.pk_url_kwarg)
    slug = self.kwargs.get(self.slug_url_kwarg)
    if (pk is not None):
        queryset = queryset.filter(pk=pk)
    if ((slug is not None) and ((pk is None) or self.query_pk_and_slug)):
        slug_field = self.get_slug_field()
        queryset = queryset.filter(**{slug_field: slug})
    if ((pk is None) and (slug is None)):
        raise AttributeError(('Generic    detail    view    %s    must    be    called    with    either    an    object    pk    or    a    slug.' % self.__class__.__name__))
    try:
        obj = queryset.get()
    except queryset.model.DoesNotExist:
        raise Http404((_('No    %(verbose_name)s    found    matching    the    query') % {'verbose_name': queryset.model._meta.verbose_name}))
    return obj
