#21619: SingleObjectMixin raises ObjectDoesNotExist, rather than a more specific subclass -----------------------------------------+-------------------- Reporter: Keryn Knight <django@…> | Owner: nobody Type: Cleanup/optimization | Status: new Component: Generic views | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------------------+-------------------- When calling `get_object` for something which inherits from SingleObjectMixin, the exception caught is [https://github.com/django/django/blob/36ded01527b690b5df0574492af9cfcc2ea3d1dc/django/views/generic/detail.py#L53 ObjectDoesNotExist], when as far as I can tell, based on the `Http404` [https://github.com/django/django/blob/36ded01527b690b5df0574492af9cfcc2ea3d1dc/django/views/generic/detail.py#L55 raised], the more specific form of `queryset.model.DoesNotExist` could be used instead.
I can't see any docs or comments as to a historic (or current) reason it may be catching the generic version (perhaps there are scenarios where the Model's `DoesNotExist` is not available yet?), and there are probably no implications by casting a wider net than necessary, but I'm opening the ticket anyway in case as a possible cleanup worth doing. -- Ticket URL: <https://code.djangoproject.com/ticket/21619> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/080.8f10e7e0dbbeea89fa76513b862a50f1%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.