Fixed #18550 -- Ensured that the admin history view works with escaped primary keys.
Thanks to josh.oosterman for the report and patch.
This commit is contained in:
parent
7313468f85
commit
2cd4cf58d3
|
@ -1321,7 +1321,7 @@ class ModelAdmin(BaseModelAdmin):
|
|||
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.
|
||||
|
|
|
@ -1344,15 +1344,20 @@ class AdminViewStringPrimaryKeyTest(TestCase):
|
|||
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):
|
||||
|
|
Loading…
Reference in New Issue