summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2011-02-26 12:44:25 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2011-02-26 12:44:25 +0000
commitb5b5ba6cd9179372cead3e6d19f732285e80b799 (patch)
tree2cdc1605a0d2d63d38d933b21a70938ba2578320 /tests
parent0b53d318ef29a34afdb4ecca1c50641760a525eb (diff)
Fixed #10918 -- Ensure that the search widget on a raw_id_admin uses the right field name when the ForeignKey has a to_field definition. Thanks to David Cramer for the report, Collin Anderson for the fix, and Julien Phalip for the test.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15657 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/admin_views/tests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 7782f9eab7..6be07b462d 100644
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -1694,6 +1694,16 @@ class AdminSearchTest(TestCase):
# confirm the search returned 1 object
self.assertContains(response, "\n1 recommendation\n")
+ def test_with_fk_to_field(self):
+ """Ensure that the to_field GET parameter is preserved when a search
+ is performed. Refs #10918.
+ """
+ from django.contrib.admin.views.main import TO_FIELD_VAR
+ response = self.client.get('/test_admin/admin/auth/user/?q=joe&%s=username' % TO_FIELD_VAR)
+ self.assertContains(response, "\n1 user\n")
+ self.assertContains(response, '<input type="hidden" name="t" value="username"/>')
+
+
class AdminInheritedInlinesTest(TestCase):
fixtures = ['admin-views-users.xml',]