Skip to content

Commit cfc3567

Browse files
committed
Fixed shortcut() crash on ObjectId pk
1 parent 80cd308 commit cfc3567

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

django/contrib/contenttypes/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.apps import apps
22
from django.contrib.contenttypes.models import ContentType
33
from django.contrib.sites.shortcuts import get_current_site
4-
from django.core.exceptions import ObjectDoesNotExist
4+
from django.core.exceptions import ObjectDoesNotExist, ValidationError
55
from django.http import Http404, HttpResponseRedirect
66
from django.utils.translation import gettext as _
77

@@ -19,7 +19,7 @@ def shortcut(request, content_type_id, object_id):
1919
% {"ct_id": content_type_id}
2020
)
2121
obj = content_type.get_object_for_this_type(pk=object_id)
22-
except (ObjectDoesNotExist, ValueError):
22+
except (ObjectDoesNotExist, ValidationError, ValueError):
2323
raise Http404(
2424
_("Content type %(ct_id)s object %(obj_id)s doesn’t exist")
2525
% {"ct_id": content_type_id, "obj_id": object_id}

0 commit comments

Comments
 (0)