def get_object(self, queryset=None):
"""
Returns the object the view is displaying.
By default this requires `self.queryset` and a `pk` or `slug` argument
in the URLconf, but subclasses can override this to return any object.
"""
obj = super(SingleObjectMixin, self).get_object(queryset=queryset)
# TODO: Consider if we want to support normal pk/slug stuff...
if not obj:
raise Http404(_("No %(verbose_name)s found matching the query") %
{'verbose_name': self.model._meta.verbose_name})
return obj
评论列表
文章目录