summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2009-12-10 19:58:20 +0000
committerKaren Tracey <kmtracey@gmail.com>2009-12-10 19:58:20 +0000
commit5543b10608fc723e7245f5d57eaa22102e863d2a (patch)
treedd343ef8ef3ba52682d8be330dafff641d22734c
parent9bf652dfd6a738fd841471f6abd71cba1b206d9f (diff)
Fixed #12349: Added missing unquote in admin history view. Thanks for the report guard.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11808 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 aab5ddbb6c..7193beeee8 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -1059,7 +1059,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 8607589289..167498ac37 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))