Opened 11 years ago
Closed 11 years ago
#21619 closed Cleanup/optimization (fixed)
SingleObjectMixin raises ObjectDoesNotExist, rather than a more specific subclass
Reported by: | Owned by: | pjrharley | |
---|---|---|---|
Component: | Generic views | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | pjrharley | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When calling get_object
for something which inherits from SingleObjectMixin, the exception caught is ObjectDoesNotExist, when as far as I can tell, based on the Http404
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.
Change History (6)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 11 years ago
Cc: | added |
---|---|
Has patch: | set |
Owner: | changed from | to
Status: | new → assigned |
Submitted PR here:
comment:4 by , 11 years ago
Patch needs improvement: | set |
---|
Hi,
I added some comments on the PR.
Once those are addressed, you can remove the patch needs improvement
flag on the ticket.
Thanks.
comment:5 by , 11 years ago
Patch needs improvement: | unset |
---|
Thanks, new commit added to the PR and some comments over there.
comment:6 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I don't see any reason why we would need the less specific exception.