summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_utils/tests.py1
-rw-r--r--tests/admin_views/tests.py12
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/admin_utils/tests.py b/tests/admin_utils/tests.py
index ecb084adbe..2e72f5a05d 100644
--- a/tests/admin_utils/tests.py
+++ b/tests/admin_utils/tests.py
@@ -259,6 +259,7 @@ class UtilsTests(SimpleTestCase):
label_for_field(lambda x: "nothing", Article),
"--"
)
+ self.assertEqual(label_for_field('site_id', Article), 'Site id')
class MockModelAdmin(object):
def test_from_model(self, obj):
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index 6455b210b2..e706ba7105 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -538,6 +538,18 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
self.assertContentBefore(response, 'The First Item', 'The Middle Item')
self.assertContentBefore(response, 'The Middle Item', 'The Last Item')
+ def test_has_related_field_in_list_display(self):
+ """Joins shouldn't be performed for <FK>_id fields in list display."""
+ state = State.objects.create(name='Karnataka')
+ City.objects.create(state=state, name='Bangalore')
+ response = self.client.get(reverse('admin:admin_views_city_changelist'), {})
+
+ response.context['cl'].list_display = ['id', 'name', 'state']
+ self.assertEqual(response.context['cl'].has_related_field_in_list_display(), True)
+
+ response.context['cl'].list_display = ['id', 'name', 'state_id']
+ self.assertEqual(response.context['cl'].has_related_field_in_list_display(), False)
+
def test_limited_filter(self):
"""Ensure admin changelist filters do not contain objects excluded via limit_choices_to.
This also tests relation-spanning filters (e.g. 'color__value').