From c31c2c92b8ef0b58394ac55fa4f61acc07091047 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Mon, 24 Dec 2012 01:32:04 +0000 Subject: [PATCH] Made admin generated changelist URLs independent of dict ordering --- django/contrib/admin/views/main.py | 2 +- tests/regressiontests/admin_filters/tests.py | 4 ++-- tests/regressiontests/admin_views/tests.py | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 5033ba98bc..be7067ff61 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -158,7 +158,7 @@ class ChangeList(object): del p[k] else: p[k] = v - return '?%s' % urlencode(p) + return '?%s' % urlencode(sorted(p.items())) def get_results(self, request): paginator = self.model_admin.get_paginator(request, self.query_set, self.list_per_page) diff --git a/tests/regressiontests/admin_filters/tests.py b/tests/regressiontests/admin_filters/tests.py index 4a3e6135c3..8a23f1c9d5 100644 --- a/tests/regressiontests/admin_filters/tests.py +++ b/tests/regressiontests/admin_filters/tests.py @@ -534,13 +534,13 @@ class ListFiltersTests(TestCase): choices = list(filterspec.choices(changelist)) self.assertEqual(choices[3]['display'], 'the 2000\'s') self.assertEqual(choices[3]['selected'], True) - self.assertEqual(choices[3]['query_string'], '?publication-decade=the+00s&author__id__exact=%s' % self.alfred.pk) + self.assertEqual(choices[3]['query_string'], '?author__id__exact=%s&publication-decade=the+00s' % self.alfred.pk) filterspec = changelist.get_filters(request)[0][0] self.assertEqual(force_text(filterspec.title), 'Verbose Author') choice = select_by(filterspec.choices(changelist), "display", "alfred") self.assertEqual(choice['selected'], True) - self.assertEqual(choice['query_string'], '?publication-decade=the+00s&author__id__exact=%s' % self.alfred.pk) + self.assertEqual(choice['query_string'], '?author__id__exact=%s&publication-decade=the+00s' % self.alfred.pk) def test_listfilter_without_title(self): """ diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index 669695ea9b..0d1e986cfa 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -3545,14 +3545,14 @@ class DateHierarchyTests(TestCase): def assert_contains_month_link(self, response, date): self.assertContains( - response, '?release_date__year=%d&release_date__month=%d"' % ( - date.year, date.month)) + response, '?release_date__month=%d&release_date__year=%d"' % ( + date.month, date.year)) def assert_contains_day_link(self, response, date): self.assertContains( - response, '?release_date__year=%d&' - 'release_date__month=%d&release_date__day=%d"' % ( - date.year, date.month, date.day)) + response, '?release_date__day=%d&' + 'release_date__month=%d&release_date__year=%d"' % ( + date.day, date.month, date.year)) def test_empty(self): """