Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #18550 -- Ensured that the admin history view works with escape…

…d primary keys.

Thanks to josh.oosterman for the report and patch.
  • Loading branch information...
commit 2cd4cf58d32c5d4b163a466f608dff31bac66b87 1 parent 7313468
@jphalip jphalip authored
View
2  django/contrib/admin/options.py
@@ -1321,7 +1321,7 @@ def history_view(self, request, object_id, extra_context=None):
opts = model._meta
app_label = opts.app_label
action_list = LogEntry.objects.filter(
- object_id = object_id,
+ object_id = unquote(object_id),
content_type__id__exact = ContentType.objects.get_for_model(model).id
).select_related().order_by('action_time')
# If no history was found, see whether this object even exists.
View
9 tests/regressiontests/admin_views/tests.py
@@ -1344,15 +1344,20 @@ def __init__(self, *args):
def setUp(self):
self.client.login(username='super', password='secret')
content_type_pk = ContentType.objects.get_for_model(ModelWithStringPrimaryKey).pk
- LogEntry.objects.log_action(100, content_type_pk, self.pk, self.pk, 2, change_message='')
+ LogEntry.objects.log_action(100, content_type_pk, self.pk, self.pk, 2, change_message='Changed something')
def tearDown(self):
self.client.logout()
def test_get_history_view(self):
- "Retrieving the history for the object using urlencoded form of primary key should work"
+ """
+ Retrieving the history for an object using urlencoded form of primary
+ key should work.
+ Refs #12349, #18550.
+ """
response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/history/' % quote(self.pk))
self.assertContains(response, escape(self.pk))
+ self.assertContains(response, 'Changed something')
self.assertEqual(response.status_code, 200)
def test_get_change_view(self):
Please sign in to comment.
Something went wrong with that request. Please try again.