Skip to content

Commit

Permalink
Fixed shortcut() crash
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Feb 21, 2025
1 parent 124a57c commit 8e24244
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django/contrib/contenttypes/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.apps import apps
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.shortcuts import get_current_site
from django.core.exceptions import ObjectDoesNotExist
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.http import Http404, HttpResponseRedirect
from django.utils.translation import gettext as _

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

0 comments on commit 8e24244

Please sign in to comment.