def get_object(self, queryset=None):
"""
Override default behavior from django.views.generic.SingleObjectMixin
to exclusively get the Quip object by its uuid.
"""
if queryset is None:
queryset = self.get_queryset()
uuid = self.kwargs.get('uuid')
try:
queryset = queryset.filter(uuid=uuid)
obj = queryset.get()
except (ValidationError, ValueError, queryset.model.DoesNotExist):
# ValidationError and ValueError are to deal with malformed inputs
# that aren't valid uuids.
raise Http404(_("No %(verbose_name)s found matching the query") %
{'verbose_name': queryset.model._meta.verbose_name})
return obj
评论列表
文章目录