mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #21619 -- Made SingleObjectMixin.get_object catch a more precise exception.
Thanks to Keryn Knight for the report.
This commit is contained in:
committed by
Baptiste Mispelon
parent
a1bc3683ff
commit
cdd6617da6
@@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import models
|
||||
from django.http import Http404
|
||||
from django.utils.translation import ugettext as _
|
||||
@@ -50,7 +50,7 @@ class SingleObjectMixin(ContextMixin):
|
||||
try:
|
||||
# Get the single item from the filtered queryset
|
||||
obj = queryset.get()
|
||||
except ObjectDoesNotExist:
|
||||
except queryset.model.DoesNotExist:
|
||||
raise Http404(_("No %(verbose_name)s found matching the query") %
|
||||
{'verbose_name': queryset.model._meta.verbose_name})
|
||||
return obj
|
||||
|
||||
Reference in New Issue
Block a user