summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2009-12-10 20:01:59 +0000
committerKaren Tracey <kmtracey@gmail.com>2009-12-10 20:01:59 +0000
commit79d8d683d226a34edc268bce0a3d9056d60ae8e8 (patch)
treed09adbcfaca2d05e8d483d29f0d172820b5ad6b8
parent58c19c324b9d648ee8ae2d12efd4d102ce5096d2 (diff)
[1.1.X] Fixed #12349: Added missing unquote in admin history view. Thanks for the report guard.
r11808 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@11809 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/admin/options.py2
-rw-r--r--tests/regressiontests/admin_views/tests.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 3144a22a2a..6fa8f5c8dd 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -1052,7 +1052,7 @@ class ModelAdmin(BaseModelAdmin):
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.
- obj = get_object_or_404(model, pk=object_id)
+ obj = get_object_or_404(model, pk=unquote(object_id))
context = {
'title': _('Change history: %s') % force_unicode(obj),
'action_list': action_list,
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 170ddf33a5..f18e578d3f 100644
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -610,6 +610,12 @@ class AdminViewStringPrimaryKeyTest(TestCase):
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"
+ response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/history/' % quote(self.pk))
+ self.assertContains(response, escape(self.pk))
+ self.failUnlessEqual(response.status_code, 200)
+
def test_get_change_view(self):
"Retrieving the object using urlencoded form of primary key should work"
response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/' % quote(self.pk))