Edited model check messages for grammar and consistency.
This commit is contained in:
parent
f7587b20da
commit
bc4dc6e99c
|
@ -67,7 +67,7 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
|
||||||
'Field names must not end with an underscore.',
|
'Field names must not end with an underscore.',
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=self,
|
obj=self,
|
||||||
id='contenttypes.E001',
|
id='fields.E001',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
|
@ -82,7 +82,7 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
|
||||||
"The GenericForeignKey object ID references the non-existent field '%s'." % self.fk_field,
|
"The GenericForeignKey object ID references the non-existent field '%s'." % self.fk_field,
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=self,
|
obj=self,
|
||||||
id='contenttypes.E002',
|
id='contenttypes.E001',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
|
@ -102,7 +102,7 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
|
||||||
),
|
),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=self,
|
obj=self,
|
||||||
id='contenttypes.E003',
|
id='contenttypes.E002',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
|
@ -114,7 +114,7 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
|
||||||
),
|
),
|
||||||
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
|
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
|
||||||
obj=self,
|
obj=self,
|
||||||
id='contenttypes.E004',
|
id='contenttypes.E003',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
elif field.rel.to != ContentType:
|
elif field.rel.to != ContentType:
|
||||||
|
@ -125,7 +125,7 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
|
||||||
),
|
),
|
||||||
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
|
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
|
||||||
obj=self,
|
obj=self,
|
||||||
id='contenttypes.E005',
|
id='contenttypes.E004',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
|
@ -282,7 +282,7 @@ class GenericRelation(ForeignObject):
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
checks.Warning(
|
checks.Error(
|
||||||
("The GenericRelation defines a relation with the model "
|
("The GenericRelation defines a relation with the model "
|
||||||
"'%s.%s', but that model does not have a GenericForeignKey.") % (
|
"'%s.%s', but that model does not have a GenericForeignKey.") % (
|
||||||
target._meta.app_label, target._meta.object_name
|
target._meta.app_label, target._meta.object_name
|
||||||
|
|
|
@ -1078,26 +1078,22 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
errors.append(
|
errors.append(
|
||||||
checks.Error(
|
checks.Error(
|
||||||
'"%s" is not of the form "app_label.app_name".' % cls._meta.swappable,
|
"'%s' is not of the form 'app_label.app_name'." % cls._meta.swappable,
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=cls,
|
obj=None,
|
||||||
id='E002',
|
id='models.E001',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except LookupError:
|
except LookupError:
|
||||||
app_label, model_name = cls._meta.swapped.split('.')
|
app_label, model_name = cls._meta.swapped.split('.')
|
||||||
errors.append(
|
errors.append(
|
||||||
checks.Error(
|
checks.Error(
|
||||||
('The model has been swapped out for %s.%s '
|
("'%s' references '%s.%s', which has not been installed, or is abstract.") % (
|
||||||
'which has not been installed or is abstract.') % (
|
cls._meta.swappable, app_label, model_name
|
||||||
app_label, model_name
|
|
||||||
),
|
),
|
||||||
hint=('Ensure that you did not misspell the model '
|
hint=None,
|
||||||
'name and the app name as well as the model '
|
obj=None,
|
||||||
'is not abstract. Does your INSTALLED_APPS '
|
id='models.E002',
|
||||||
'setting contain the "%s" app?') % app_label,
|
|
||||||
obj=cls,
|
|
||||||
id='E003',
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return errors
|
return errors
|
||||||
|
@ -1144,13 +1140,14 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
if signature in seen_intermediary_signatures:
|
if signature in seen_intermediary_signatures:
|
||||||
errors.append(
|
errors.append(
|
||||||
checks.Error(
|
checks.Error(
|
||||||
('The model has two many-to-many relations through '
|
("The model has two many-to-many relations through "
|
||||||
'the intermediary %s model, which is not permitted.') % (
|
"the intermediate model '%s.%s'.") % (
|
||||||
|
f.rel.through._meta.app_label,
|
||||||
f.rel.through._meta.object_name
|
f.rel.through._meta.object_name
|
||||||
),
|
),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E004',
|
id='models.E003',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -1167,13 +1164,11 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
if fields and not fields[0].primary_key and cls._meta.pk.name == 'id':
|
if fields and not fields[0].primary_key and cls._meta.pk.name == 'id':
|
||||||
return [
|
return [
|
||||||
checks.Error(
|
checks.Error(
|
||||||
('You cannot use "id" as a field name, because each model '
|
("'id' can only be used as a field name if the field also "
|
||||||
'automatically gets an "id" field if none '
|
"sets 'primary_key=True'."),
|
||||||
'of the fields have primary_key=True.'),
|
hint=None,
|
||||||
hint=('Remove or rename "id" field '
|
|
||||||
'or add primary_key=True to a field.'),
|
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E005',
|
id='models.E004',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
|
@ -1193,15 +1188,15 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
if clash:
|
if clash:
|
||||||
errors.append(
|
errors.append(
|
||||||
checks.Error(
|
checks.Error(
|
||||||
('The field "%s" from parent model '
|
("The field '%s' from parent model "
|
||||||
'%s clashes with the field "%s" '
|
"'%s' clashes with the field '%s' "
|
||||||
'from parent model %s.') % (
|
"from parent model '%s'.") % (
|
||||||
clash.name, clash.model._meta,
|
clash.name, clash.model._meta,
|
||||||
f.name, f.model._meta
|
f.name, f.model._meta
|
||||||
),
|
),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E053',
|
id='models.E005',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
used_fields[f.name] = f
|
used_fields[f.name] = f
|
||||||
|
@ -1220,13 +1215,13 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
if clash and not id_conflict:
|
if clash and not id_conflict:
|
||||||
errors.append(
|
errors.append(
|
||||||
checks.Error(
|
checks.Error(
|
||||||
('The field clashes with the field "%s" '
|
("The field '%s' clashes with the field '%s' "
|
||||||
'from model %s.') % (
|
"from model '%s'.") % (
|
||||||
clash.name, clash.model._meta
|
f.name, clash.name, clash.model._meta
|
||||||
),
|
),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=f,
|
obj=f,
|
||||||
id='E054',
|
id='models.E006',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
used_fields[f.name] = f
|
used_fields[f.name] = f
|
||||||
|
@ -1247,9 +1242,10 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
if column_name and column_name in used_column_names:
|
if column_name and column_name in used_column_names:
|
||||||
errors.append(
|
errors.append(
|
||||||
checks.Error(
|
checks.Error(
|
||||||
'Field "%s" has column name "%s" that is already used.' % (f.name, column_name),
|
"Field '%s' has column name '%s' that is used by another field." % (f.name, column_name),
|
||||||
hint=None,
|
hint="Specify a 'db_column' for the field.",
|
||||||
obj=cls,
|
obj=cls,
|
||||||
|
id='models.E007'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -1263,10 +1259,10 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
if not isinstance(cls._meta.index_together, (tuple, list)):
|
if not isinstance(cls._meta.index_together, (tuple, list)):
|
||||||
return [
|
return [
|
||||||
checks.Error(
|
checks.Error(
|
||||||
'"index_together" must be a list or tuple.',
|
"'index_together' must be a list or tuple.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E006',
|
id='models.E008',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1274,10 +1270,10 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
for fields in cls._meta.index_together):
|
for fields in cls._meta.index_together):
|
||||||
return [
|
return [
|
||||||
checks.Error(
|
checks.Error(
|
||||||
'All "index_together" elements must be lists or tuples.',
|
"All 'index_together' elements must be lists or tuples.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E007',
|
id='models.E009',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1293,10 +1289,10 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
if not isinstance(cls._meta.unique_together, (tuple, list)):
|
if not isinstance(cls._meta.unique_together, (tuple, list)):
|
||||||
return [
|
return [
|
||||||
checks.Error(
|
checks.Error(
|
||||||
'"unique_together" must be a list or tuple.',
|
"'unique_together' must be a list or tuple.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E008',
|
id='models.E010',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1304,10 +1300,10 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
for fields in cls._meta.unique_together):
|
for fields in cls._meta.unique_together):
|
||||||
return [
|
return [
|
||||||
checks.Error(
|
checks.Error(
|
||||||
'All "unique_together" elements must be lists or tuples.',
|
"All 'unique_together' elements must be lists or tuples.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E009',
|
id='models.E011',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1329,23 +1325,23 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
except models.FieldDoesNotExist:
|
except models.FieldDoesNotExist:
|
||||||
errors.append(
|
errors.append(
|
||||||
checks.Error(
|
checks.Error(
|
||||||
'"%s" points to a missing field named "%s".' % (option, field_name),
|
"'%s' refers to the non-existent field '%s'." % (option, field_name),
|
||||||
hint='Ensure that you did not misspell the field name.',
|
hint=None,
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E010',
|
id='models.E012',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if isinstance(field.rel, models.ManyToManyRel):
|
if isinstance(field.rel, models.ManyToManyRel):
|
||||||
errors.append(
|
errors.append(
|
||||||
checks.Error(
|
checks.Error(
|
||||||
('"%s" refers to a m2m "%s" field, but '
|
("'%s' refers to a ManyToManyField '%s', but "
|
||||||
'ManyToManyFields are not supported in "%s".') % (
|
"ManyToManyFields are not permitted in '%s'.") % (
|
||||||
option, field_name, option
|
option, field_name, option
|
||||||
),
|
),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E011',
|
id='models.E013',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return errors
|
return errors
|
||||||
|
@ -1363,11 +1359,11 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
if not isinstance(cls._meta.ordering, (list, tuple)):
|
if not isinstance(cls._meta.ordering, (list, tuple)):
|
||||||
return [
|
return [
|
||||||
checks.Error(
|
checks.Error(
|
||||||
('"ordering" must be a tuple or list '
|
("'ordering' must be a tuple or list "
|
||||||
'(even if you want to order by only one field).'),
|
"(even if you want to order by only one field)."),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E012',
|
id='models.E014',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1398,10 +1394,10 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
except FieldDoesNotExist:
|
except FieldDoesNotExist:
|
||||||
errors.append(
|
errors.append(
|
||||||
checks.Error(
|
checks.Error(
|
||||||
'"ordering" pointing to a missing "%s" field.' % field_name,
|
"'ordering' refers to the non-existent field '%s'." % field_name,
|
||||||
hint='Ensure that you did not misspell the field name.',
|
hint=None,
|
||||||
obj=cls,
|
obj=cls,
|
||||||
id='E013',
|
id='models.E015',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return errors
|
return errors
|
||||||
|
|
|
@ -109,7 +109,7 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
|
||||||
"The GenericForeignKey content type references the non-existent field 'TaggedItem.content_type'.",
|
"The GenericForeignKey content type references the non-existent field 'TaggedItem.content_type'.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=TaggedItem.content_object,
|
obj=TaggedItem.content_object,
|
||||||
id='contenttypes.E003',
|
id='contenttypes.E002',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -127,7 +127,7 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
|
||||||
"'Model.content_type' is not a ForeignKey.",
|
"'Model.content_type' is not a ForeignKey.",
|
||||||
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
|
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
|
||||||
obj=Model.content_object,
|
obj=Model.content_object,
|
||||||
id='contenttypes.E004',
|
id='contenttypes.E003',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -145,7 +145,7 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
|
||||||
"'Model.content_type' is not a ForeignKey to 'contenttypes.ContentType'.",
|
"'Model.content_type' is not a ForeignKey to 'contenttypes.ContentType'.",
|
||||||
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
|
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
|
||||||
obj=Model.content_object,
|
obj=Model.content_object,
|
||||||
id='contenttypes.E005',
|
id='contenttypes.E004',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -162,7 +162,7 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
|
||||||
"The GenericForeignKey object ID references the non-existent field 'object_id'.",
|
"The GenericForeignKey object ID references the non-existent field 'object_id'.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=TaggedItem.content_object,
|
obj=TaggedItem.content_object,
|
||||||
id='contenttypes.E002',
|
id='contenttypes.E001',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -180,7 +180,7 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
|
||||||
'Field names must not end with an underscore.',
|
'Field names must not end with an underscore.',
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model.content_object_,
|
obj=Model.content_object_,
|
||||||
id='contenttypes.E001',
|
id='fields.E001',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -265,7 +265,7 @@ class GenericRelationshipTests(IsolatedModelsTestCase):
|
||||||
|
|
||||||
errors = Bookmark.tags.field.check()
|
errors = Bookmark.tags.field.check()
|
||||||
expected = [
|
expected = [
|
||||||
checks.Warning(
|
checks.Error(
|
||||||
("The GenericRelation defines a relation with the model "
|
("The GenericRelation defines a relation with the model "
|
||||||
"'contenttypes_tests.TaggedItem', but that model does not have a "
|
"'contenttypes_tests.TaggedItem', but that model does not have a "
|
||||||
"GenericForeignKey."),
|
"GenericForeignKey."),
|
||||||
|
|
|
@ -18,10 +18,10 @@ class IndexTogetherTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
'"index_together" must be a list or tuple.',
|
"'index_together' must be a list or tuple.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E006',
|
id='models.E008',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -34,10 +34,10 @@ class IndexTogetherTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
'"index_together" must be a list or tuple.',
|
"'index_together' must be a list or tuple.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E006',
|
id='models.E008',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -50,10 +50,10 @@ class IndexTogetherTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
'All "index_together" elements must be lists or tuples.',
|
"All 'index_together' elements must be lists or tuples.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E007',
|
id='models.E009',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -68,10 +68,10 @@ class IndexTogetherTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
'"index_together" points to a missing field named "missing_field".',
|
"'index_together' refers to the non-existent field 'missing_field'.",
|
||||||
hint='Ensure that you did not misspell the field name.',
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E010',
|
id='models.E012',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -88,11 +88,11 @@ class IndexTogetherTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
('"index_together" refers to a m2m "m2m" field, but '
|
("'index_together' refers to a ManyToManyField 'm2m', but "
|
||||||
'ManyToManyFields are not supported in "index_together".'),
|
"ManyToManyFields are not permitted in 'index_together'."),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E011',
|
id='models.E013',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -109,10 +109,10 @@ class UniqueTogetherTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
'"unique_together" must be a list or tuple.',
|
"'unique_together' must be a list or tuple.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E008',
|
id='models.E010',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -128,10 +128,10 @@ class UniqueTogetherTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
'All "unique_together" elements must be lists or tuples.',
|
"All 'unique_together' elements must be lists or tuples.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E009',
|
id='models.E011',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -144,10 +144,10 @@ class UniqueTogetherTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
'"unique_together" must be a list or tuple.',
|
"'unique_together' must be a list or tuple.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E008',
|
id='models.E010',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -174,10 +174,10 @@ class UniqueTogetherTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
'"unique_together" points to a missing field named "missing_field".',
|
"'unique_together' refers to the non-existent field 'missing_field'.",
|
||||||
hint='Ensure that you did not misspell the field name.',
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E010',
|
id='models.E012',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -194,11 +194,11 @@ class UniqueTogetherTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
('"unique_together" refers to a m2m "m2m" field, but '
|
("'unique_together' refers to a ManyToManyField 'm2m', but "
|
||||||
'ManyToManyFields are not supported in "unique_together".'),
|
"ManyToManyFields are not permitted in 'unique_together'."),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E011',
|
id='models.E013',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -276,20 +276,20 @@ class ShadowingFieldsTests(IsolatedModelsTestCase):
|
||||||
errors = Child.check()
|
errors = Child.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
('The field "id" from parent model '
|
("The field 'id' from parent model "
|
||||||
'invalid_models_tests.mother clashes with the field "id" '
|
"'invalid_models_tests.mother' clashes with the field 'id' "
|
||||||
'from parent model invalid_models_tests.father.'),
|
"from parent model 'invalid_models_tests.father'."),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Child,
|
obj=Child,
|
||||||
id='E053',
|
id='models.E005',
|
||||||
),
|
),
|
||||||
Error(
|
Error(
|
||||||
('The field "clash" from parent model '
|
("The field 'clash' from parent model "
|
||||||
'invalid_models_tests.mother clashes with the field "clash" '
|
"'invalid_models_tests.mother' clashes with the field 'clash' "
|
||||||
'from parent model invalid_models_tests.father.'),
|
"from parent model 'invalid_models_tests.father'."),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Child,
|
obj=Child,
|
||||||
id='E053',
|
id='models.E005',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -309,11 +309,11 @@ class ShadowingFieldsTests(IsolatedModelsTestCase):
|
||||||
errors = Child.check()
|
errors = Child.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
('The field clashes with the field "f_id" '
|
("The field 'f' clashes with the field 'f_id' "
|
||||||
'from model invalid_models_tests.parent.'),
|
"from model 'invalid_models_tests.parent'."),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Child._meta.get_field('f'),
|
obj=Child._meta.get_field('f'),
|
||||||
id='E054',
|
id='models.E006',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -329,11 +329,11 @@ class ShadowingFieldsTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
('The field clashes with the field "fk" from model '
|
("The field 'fk_id' clashes with the field 'fk' from model "
|
||||||
'invalid_models_tests.model.'),
|
"'invalid_models_tests.model'."),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model._meta.get_field('fk_id'),
|
obj=Model._meta.get_field('fk_id'),
|
||||||
id='E054',
|
id='models.E006',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -350,12 +350,10 @@ class OtherModelTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
('You cannot use "id" as a field name, because each model '
|
"'id' can only be used as a field name if the field also sets 'primary_key=True'.",
|
||||||
'automatically gets an "id" field if none of the fields '
|
hint=None,
|
||||||
'have primary_key=True.'),
|
|
||||||
hint='Remove or rename "id" field or add primary_key=True to a field.',
|
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E005',
|
id='models.E004',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -368,11 +366,11 @@ class OtherModelTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
('"ordering" must be a tuple or list '
|
("'ordering' must be a tuple or list "
|
||||||
'(even if you want to order by only one field).'),
|
"(even if you want to order by only one field)."),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E012',
|
id='models.E014',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -385,10 +383,10 @@ class OtherModelTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
'"ordering" pointing to a missing "missing_field" field.',
|
"'ordering' refers to the non-existent field 'missing_field'.",
|
||||||
hint='Ensure that you did not misspell the field name.',
|
hint=None,
|
||||||
obj=Model,
|
obj=Model,
|
||||||
id='E013',
|
id='models.E015',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -402,10 +400,10 @@ class OtherModelTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
'"TEST_SWAPPED_MODEL_BAD_VALUE" is not of the form "app_label.app_name".',
|
"'TEST_SWAPPED_MODEL_BAD_VALUE' is not of the form 'app_label.app_name'.",
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Model,
|
obj=None,
|
||||||
id='E002',
|
id='models.E001',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -419,13 +417,11 @@ class OtherModelTests(IsolatedModelsTestCase):
|
||||||
errors = Model.check()
|
errors = Model.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
('The model has been swapped out for not_an_app.Target '
|
("'TEST_SWAPPED_MODEL_BAD_MODEL' references 'not_an_app.Target', "
|
||||||
'which has not been installed or is abstract.'),
|
'which has not been installed, or is abstract.'),
|
||||||
hint=('Ensure that you did not misspell the model name and '
|
hint=None,
|
||||||
'the app name as well as the model is not abstract. Does '
|
obj=None,
|
||||||
'your INSTALLED_APPS setting contain the "not_an_app" app?'),
|
id='models.E002',
|
||||||
obj=Model,
|
|
||||||
id='E003',
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
@ -447,11 +443,11 @@ class OtherModelTests(IsolatedModelsTestCase):
|
||||||
errors = Group.check()
|
errors = Group.check()
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
('The model has two many-to-many relations through '
|
("The model has two many-to-many relations through "
|
||||||
'the intermediary Membership model, which is not permitted.'),
|
"the intermediate model 'invalid_models_tests.Membership'."),
|
||||||
hint=None,
|
hint=None,
|
||||||
obj=Group,
|
obj=Group,
|
||||||
id='E004',
|
id='models.E003',
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.assertEqual(errors, expected)
|
self.assertEqual(errors, expected)
|
||||||
|
|
Loading…
Reference in New Issue