summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2021-03-03 14:59:45 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-03-04 08:41:28 +0100
commit1da54bfe7d4f3a2a24dc4f724a3538414a02462d (patch)
tree4b37915ade3d98fdc3e0392046b5a6fb7cde6cb4
parentd1f89c9b9a9b44c4dbfd24fcb5f76f16e973c0a2 (diff)
Corrected messages of admin checks for invalid model field names.
-rw-r--r--django/contrib/admin/checks.py4
-rw-r--r--docs/ref/checks.txt16
-rw-r--r--tests/admin_checks/tests.py4
-rw-r--r--tests/modeladmin/test_checks.py18
4 files changed, 21 insertions, 21 deletions
diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
index fea5e24b7c..35760a1177 100644
--- a/django/contrib/admin/checks.py
+++ b/django/contrib/admin/checks.py
@@ -1129,8 +1129,8 @@ def must_inherit_from(parent, option, obj, id):
def refer_to_missing_field(field, option, obj, id):
return [
checks.Error(
- "The value of '%s' refers to '%s', which is not an attribute of "
- "'%s'." % (option, field, obj.model._meta.label),
+ "The value of '%s' refers to '%s', which is not a field of '%s'."
+ % (option, field, obj.model._meta.label),
obj=obj.__class__,
id=id,
),
diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt
index 54ae9c47ce..3a55884502 100644
--- a/docs/ref/checks.txt
+++ b/docs/ref/checks.txt
@@ -594,7 +594,7 @@ with the admin site:
* **admin.E001**: The value of ``raw_id_fields`` must be a list or tuple.
* **admin.E002**: The value of ``raw_id_fields[n]`` refers to ``<field name>``,
- which is not an attribute of ``<model>``.
+ which is not a field of ``<model>``.
* **admin.E003**: The value of ``raw_id_fields[n]`` must be a foreign key or
a many-to-many field.
* **admin.E004**: The value of ``fields`` must be a list or tuple.
@@ -616,12 +616,12 @@ with the admin site:
* **admin.E017**: The value of ``filter_vertical`` must be a list or tuple.
* **admin.E018**: The value of ``filter_horizontal`` must be a list or tuple.
* **admin.E019**: The value of ``filter_vertical[n]/filter_horizontal[n]``
- refers to ``<field name>``, which is not an attribute of ``<model>``.
+ refers to ``<field name>``, which is not a field of ``<model>``.
* **admin.E020**: The value of ``filter_vertical[n]/filter_horizontal[n]``
must be a many-to-many field.
* **admin.E021**: The value of ``radio_fields`` must be a dictionary.
* **admin.E022**: The value of ``radio_fields`` refers to ``<field name>``,
- which is not an attribute of ``<model>``.
+ which is not a field of ``<model>``.
* **admin.E023**: The value of ``radio_fields`` refers to ``<field name>``,
which is not instance of ``ForeignKey``, and does not have a ``choices``
definition.
@@ -631,25 +631,25 @@ with the admin site:
boolean value.
* **admin.E026**: The value of ``prepopulated_fields`` must be a dictionary.
* **admin.E027**: The value of ``prepopulated_fields`` refers to
- ``<field name>``, which is not an attribute of ``<model>``.
+ ``<field name>``, which is not a field of ``<model>``.
* **admin.E028**: The value of ``prepopulated_fields`` refers to
``<field name>``, which must not be a ``DateTimeField``, a ``ForeignKey``,
a ``OneToOneField``, or a ``ManyToManyField`` field.
* **admin.E029**: The value of ``prepopulated_fields[<field name>]`` must be a
list or tuple.
* **admin.E030**: The value of ``prepopulated_fields`` refers to
- ``<field name>``, which is not an attribute of ``<model>``.
+ ``<field name>``, which is not a field of ``<model>``.
* **admin.E031**: The value of ``ordering`` must be a list or tuple.
* **admin.E032**: The value of ``ordering`` has the random ordering marker
``?``, but contains other fields as well.
* **admin.E033**: The value of ``ordering`` refers to ``<field name>``, which
- is not an attribute of ``<model>``.
+ is not a field of ``<model>``.
* **admin.E034**: The value of ``readonly_fields`` must be a list or tuple.
* **admin.E035**: The value of ``readonly_fields[n]`` is not a callable, an
attribute of ``<ModelAdmin class>``, or an attribute of ``<model>``.
* **admin.E036**: The value of ``autocomplete_fields`` must be a list or tuple.
* **admin.E037**: The value of ``autocomplete_fields[n]`` refers to
- ``<field name>``, which is not an attribute of ``<model>``.
+ ``<field name>``, which is not a field of ``<model>``.
* **admin.E038**: The value of ``autocomplete_fields[n]`` must be a foreign
key or a many-to-many field.
* **admin.E039**: An admin for model ``<model>`` has to be registered to be
@@ -697,7 +697,7 @@ with the admin site:
* **admin.E119**: The value of ``list_max_show_all`` must be an integer.
* **admin.E120**: The value of ``list_editable`` must be a list or tuple.
* **admin.E121**: The value of ``list_editable[n]`` refers to ``<label>``,
- which is not an attribute of ``<model>``.
+ which is not a field of ``<model>``.
* **admin.E122**: The value of ``list_editable[n]`` refers to ``<label>``,
which is not contained in ``list_display``.
* **admin.E123**: The value of ``list_editable[n]`` cannot be in both
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py
index 139b6dec59..67625c7c86 100644
--- a/tests/admin_checks/tests.py
+++ b/tests/admin_checks/tests.py
@@ -309,7 +309,7 @@ class SystemChecksTestCase(SimpleTestCase):
self.assertEqual(SongAdmin(Song, AdminSite()).check(), [
checks.Error(
"The value of 'list_editable[0]' refers to 'test', which is "
- "not an attribute of 'admin_checks.Song'.",
+ "not a field of 'admin_checks.Song'.",
obj=SongAdmin,
id='admin.E121',
)
@@ -618,7 +618,7 @@ class SystemChecksTestCase(SimpleTestCase):
expected = [
checks.Error(
"The value of 'raw_id_fields[0]' refers to 'nonexistent', "
- "which is not an attribute of 'admin_checks.Album'.",
+ "which is not a field of 'admin_checks.Album'.",
obj=RawIdNonexistentAdmin,
id='admin.E002',
)
diff --git a/tests/modeladmin/test_checks.py b/tests/modeladmin/test_checks.py
index d81cc3dd32..46d18b32ca 100644
--- a/tests/modeladmin/test_checks.py
+++ b/tests/modeladmin/test_checks.py
@@ -63,7 +63,7 @@ class RawIdCheckTests(CheckTestCase):
self.assertIsInvalid(
TestModelAdmin, ValidationTestModel,
"The value of 'raw_id_fields[0]' refers to 'non_existent_field', "
- "which is not an attribute of 'modeladmin.ValidationTestModel'.",
+ "which is not a field of 'modeladmin.ValidationTestModel'.",
'admin.E002'
)
@@ -278,7 +278,7 @@ class FilterVerticalCheckTests(CheckTestCase):
self.assertIsInvalid(
TestModelAdmin, ValidationTestModel,
"The value of 'filter_vertical[0]' refers to 'non_existent_field', "
- "which is not an attribute of 'modeladmin.ValidationTestModel'.",
+ "which is not a field of 'modeladmin.ValidationTestModel'.",
'admin.E019'
)
@@ -318,7 +318,7 @@ class FilterHorizontalCheckTests(CheckTestCase):
self.assertIsInvalid(
TestModelAdmin, ValidationTestModel,
"The value of 'filter_horizontal[0]' refers to 'non_existent_field', "
- "which is not an attribute of 'modeladmin.ValidationTestModel'.",
+ "which is not a field of 'modeladmin.ValidationTestModel'.",
'admin.E019'
)
@@ -359,7 +359,7 @@ class RadioFieldsCheckTests(CheckTestCase):
self.assertIsInvalid(
TestModelAdmin, ValidationTestModel,
"The value of 'radio_fields' refers to 'non_existent_field', "
- "which is not an attribute of 'modeladmin.ValidationTestModel'.",
+ "which is not a field of 'modeladmin.ValidationTestModel'.",
'admin.E022'
)
@@ -421,7 +421,7 @@ class PrepopulatedFieldsCheckTests(CheckTestCase):
self.assertIsInvalid(
TestModelAdmin, ValidationTestModel,
"The value of 'prepopulated_fields' refers to 'non_existent_field', "
- "which is not an attribute of 'modeladmin.ValidationTestModel'.",
+ "which is not a field of 'modeladmin.ValidationTestModel'.",
'admin.E027'
)
@@ -432,7 +432,7 @@ class PrepopulatedFieldsCheckTests(CheckTestCase):
self.assertIsInvalid(
TestModelAdmin, ValidationTestModel,
"The value of 'prepopulated_fields[\"slug\"][0]' refers to 'non_existent_field', "
- "which is not an attribute of 'modeladmin.ValidationTestModel'.",
+ "which is not a field of 'modeladmin.ValidationTestModel'.",
'admin.E030'
)
@@ -873,7 +873,7 @@ class OrderingCheckTests(CheckTestCase):
self.assertIsInvalid(
TestModelAdmin, ValidationTestModel,
"The value of 'ordering[0]' refers to 'non_existent_field', "
- "which is not an attribute of 'modeladmin.ValidationTestModel'.",
+ "which is not a field of 'modeladmin.ValidationTestModel'.",
'admin.E033'
)
@@ -914,7 +914,7 @@ class OrderingCheckTests(CheckTestCase):
self.assertIsInvalid(
TestModelAdmin, ValidationTestModel,
"The value of 'ordering[0]' refers to 'nonexistent', which is not "
- "an attribute of 'modeladmin.ValidationTestModel'.",
+ "a field of 'modeladmin.ValidationTestModel'.",
'admin.E033'
)
@@ -1342,7 +1342,7 @@ class AutocompleteFieldsTests(CheckTestCase):
Admin, ValidationTestModel,
msg=(
"The value of 'autocomplete_fields[0]' refers to 'nonexistent', "
- "which is not an attribute of 'modeladmin.ValidationTestModel'."
+ "which is not a field of 'modeladmin.ValidationTestModel'."
),
id='admin.E037',
invalid_obj=Admin,