mirror of
https://github.com/django/django.git
synced 2025-08-19 02:01:29 +00:00
[1.8.x] Fixed #24333 -- Fixed admin history view crash with non-integer slug.
Backport of d64baaef3b
from master
This commit is contained in:
parent
6476fa73d3
commit
03f4e2d909
2 changed files with 11 additions and 2 deletions
|
@ -39,7 +39,6 @@ from django.forms.models import (
|
|||
from django.forms.widgets import CheckboxSelectMultiple, SelectMultiple
|
||||
from django.http import Http404, HttpResponseRedirect
|
||||
from django.http.response import HttpResponseBase
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.template.response import SimpleTemplateResponse, TemplateResponse
|
||||
from django.utils import six
|
||||
from django.utils.decorators import method_decorator
|
||||
|
@ -1750,7 +1749,12 @@ class ModelAdmin(BaseModelAdmin):
|
|||
from django.contrib.admin.models import LogEntry
|
||||
# First check if the user can see this history.
|
||||
model = self.model
|
||||
obj = get_object_or_404(self.get_queryset(request), pk=unquote(object_id))
|
||||
obj = self.get_object(request, unquote(object_id))
|
||||
if obj is None:
|
||||
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {
|
||||
'name': force_text(model._meta.verbose_name),
|
||||
'key': escape(object_id),
|
||||
})
|
||||
|
||||
if not self.has_change_permission(request, obj):
|
||||
raise PermissionDenied
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue