summaryrefslogtreecommitdiff
path: root/tests/modeladmin/test_checks.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modeladmin/test_checks.py')
-rw-r--r--tests/modeladmin/test_checks.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/modeladmin/test_checks.py b/tests/modeladmin/test_checks.py
index f76b78078a..5a0433deb4 100644
--- a/tests/modeladmin/test_checks.py
+++ b/tests/modeladmin/test_checks.py
@@ -3,6 +3,8 @@ from django.contrib.admin import BooleanFieldListFilter, SimpleListFilter
from django.contrib.admin.options import VERTICAL, ModelAdmin, TabularInline
from django.contrib.admin.sites import AdminSite
from django.core.checks import Error
+from django.db.models import F
+from django.db.models.functions import Upper
from django.forms.models import BaseModelFormSet
from django.test import SimpleTestCase
@@ -829,6 +831,23 @@ class OrderingCheckTests(CheckTestCase):
self.assertIsValid(TestModelAdmin, ValidationTestModel)
+ def test_invalid_expression(self):
+ class TestModelAdmin(ModelAdmin):
+ ordering = (F('nonexistent'), )
+
+ self.assertIsInvalid(
+ TestModelAdmin, ValidationTestModel,
+ "The value of 'ordering[0]' refers to 'nonexistent', which is not "
+ "an attribute of 'modeladmin.ValidationTestModel'.",
+ 'admin.E033'
+ )
+
+ def test_valid_expression(self):
+ class TestModelAdmin(ModelAdmin):
+ ordering = (Upper('name'), Upper('band__name').desc())
+
+ self.assertIsValid(TestModelAdmin, ValidationTestModel)
+
class ListSelectRelatedCheckTests(CheckTestCase):