Permalink
Browse files

Edited model check messages for grammar and consistency.

  • Loading branch information...
1 parent f7587b2 commit bc4dc6e99c532b844a26c8a9021a4d04703e28cd @freakboy3742 freakboy3742 committed Mar 3, 2014
@@ -67,7 +67,7 @@ def _check_field_name(self):
'Field names must not end with an underscore.',
hint=None,
obj=self,
- id='contenttypes.E001',
+ id='fields.E001',
)
]
else:
@@ -82,7 +82,7 @@ def _check_object_id_field(self):
"The GenericForeignKey object ID references the non-existent field '%s'." % self.fk_field,
hint=None,
obj=self,
- id='contenttypes.E002',
+ id='contenttypes.E001',
)
]
else:
@@ -102,7 +102,7 @@ def _check_content_type_field(self):
),
hint=None,
obj=self,
- id='contenttypes.E003',
+ id='contenttypes.E002',
)
]
else:
@@ -114,7 +114,7 @@ def _check_content_type_field(self):
),
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
obj=self,
- id='contenttypes.E004',
+ id='contenttypes.E003',
)
]
elif field.rel.to != ContentType:
@@ -125,7 +125,7 @@ def _check_content_type_field(self):
),
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
obj=self,
- id='contenttypes.E005',
+ id='contenttypes.E004',
)
]
else:
@@ -282,7 +282,7 @@ def _check_generic_foreign_key_existence(self):
return []
else:
return [
- checks.Warning(
+ checks.Error(
("The GenericRelation defines a relation with the model "
"'%s.%s', but that model does not have a GenericForeignKey.") % (
target._meta.app_label, target._meta.object_name
@@ -1078,26 +1078,22 @@ def _check_swappable(cls):
except ValueError:
errors.append(
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,
- obj=cls,
- id='E002',
+ obj=None,
+ id='models.E001',
)
)
except LookupError:
app_label, model_name = cls._meta.swapped.split('.')
errors.append(
checks.Error(
- ('The model has been swapped out for %s.%s '
- 'which has not been installed or is abstract.') % (
- app_label, model_name
+ ("'%s' references '%s.%s', which has not been installed, or is abstract.") % (
+ cls._meta.swappable, app_label, model_name
),
- hint=('Ensure that you did not misspell the model '
- 'name and the app name as well as the model '
- 'is not abstract. Does your INSTALLED_APPS '
- 'setting contain the "%s" app?') % app_label,
- obj=cls,
- id='E003',
+ hint=None,
+ obj=None,
+ id='models.E002',
)
)
return errors
@@ -1144,13 +1140,14 @@ def _check_m2m_through_same_relationship(cls):
if signature in seen_intermediary_signatures:
errors.append(
checks.Error(
- ('The model has two many-to-many relations through '
- 'the intermediary %s model, which is not permitted.') % (
+ ("The model has two many-to-many relations through "
+ "the intermediate model '%s.%s'.") % (
+ f.rel.through._meta.app_label,
f.rel.through._meta.object_name
),
hint=None,
obj=cls,
- id='E004',
+ id='models.E003',
)
)
else:
@@ -1167,13 +1164,11 @@ def _check_id_field(cls):
if fields and not fields[0].primary_key and cls._meta.pk.name == 'id':
return [
checks.Error(
- ('You cannot use "id" as a field name, because each model '
- 'automatically gets an "id" field if none '
- 'of the fields have primary_key=True.'),
- hint=('Remove or rename "id" field '
- 'or add primary_key=True to a field.'),
+ ("'id' can only be used as a field name if the field also "
+ "sets 'primary_key=True'."),
+ hint=None,
obj=cls,
- id='E005',
+ id='models.E004',
)
]
else:
@@ -1193,15 +1188,15 @@ def _check_field_name_clashes(cls):
if clash:
errors.append(
checks.Error(
- ('The field "%s" from parent model '
- '%s clashes with the field "%s" '
- 'from parent model %s.') % (
+ ("The field '%s' from parent model "
+ "'%s' clashes with the field '%s' "
+ "from parent model '%s'.") % (
clash.name, clash.model._meta,
f.name, f.model._meta
),
hint=None,
obj=cls,
- id='E053',
+ id='models.E005',
)
)
used_fields[f.name] = f
@@ -1220,13 +1215,13 @@ def _check_field_name_clashes(cls):
if clash and not id_conflict:
errors.append(
checks.Error(
- ('The field clashes with the field "%s" '
- 'from model %s.') % (
- clash.name, clash.model._meta
+ ("The field '%s' clashes with the field '%s' "
+ "from model '%s'.") % (
+ f.name, clash.name, clash.model._meta
),
hint=None,
obj=f,
- id='E054',
+ id='models.E006',
)
)
used_fields[f.name] = f
@@ -1247,9 +1242,10 @@ def _check_column_name_clashes(cls):
if column_name and column_name in used_column_names:
errors.append(
checks.Error(
- 'Field "%s" has column name "%s" that is already used.' % (f.name, column_name),
- hint=None,
+ "Field '%s' has column name '%s' that is used by another field." % (f.name, column_name),
+ hint="Specify a 'db_column' for the field.",
obj=cls,
+ id='models.E007'
)
)
else:
@@ -1263,21 +1259,21 @@ def _check_index_together(cls):
if not isinstance(cls._meta.index_together, (tuple, list)):
return [
checks.Error(
- '"index_together" must be a list or tuple.',
+ "'index_together' must be a list or tuple.",
hint=None,
obj=cls,
- id='E006',
+ id='models.E008',
)
]
elif any(not isinstance(fields, (tuple, list))
for fields in cls._meta.index_together):
return [
checks.Error(
- 'All "index_together" elements must be lists or tuples.',
+ "All 'index_together' elements must be lists or tuples.",
hint=None,
obj=cls,
- id='E007',
+ id='models.E009',
)
]
@@ -1293,21 +1289,21 @@ def _check_unique_together(cls):
if not isinstance(cls._meta.unique_together, (tuple, list)):
return [
checks.Error(
- '"unique_together" must be a list or tuple.',
+ "'unique_together' must be a list or tuple.",
hint=None,
obj=cls,
- id='E008',
+ id='models.E010',
)
]
elif any(not isinstance(fields, (tuple, list))
for fields in cls._meta.unique_together):
return [
checks.Error(
- 'All "unique_together" elements must be lists or tuples.',
+ "All 'unique_together' elements must be lists or tuples.",
hint=None,
obj=cls,
- id='E009',
+ id='models.E011',
)
]
@@ -1329,23 +1325,23 @@ def _check_local_fields(cls, fields, option):
except models.FieldDoesNotExist:
errors.append(
checks.Error(
- '"%s" points to a missing field named "%s".' % (option, field_name),
- hint='Ensure that you did not misspell the field name.',
+ "'%s' refers to the non-existent field '%s'." % (option, field_name),
+ hint=None,
obj=cls,
- id='E010',
+ id='models.E012',
)
)
else:
if isinstance(field.rel, models.ManyToManyRel):
errors.append(
checks.Error(
- ('"%s" refers to a m2m "%s" field, but '
- 'ManyToManyFields are not supported in "%s".') % (
+ ("'%s' refers to a ManyToManyField '%s', but "
+ "ManyToManyFields are not permitted in '%s'.") % (
option, field_name, option
),
hint=None,
obj=cls,
- id='E011',
+ id='models.E013',
)
)
return errors
@@ -1363,11 +1359,11 @@ def _check_ordering(cls):
if not isinstance(cls._meta.ordering, (list, tuple)):
return [
checks.Error(
- ('"ordering" must be a tuple or list '
- '(even if you want to order by only one field).'),
+ ("'ordering' must be a tuple or list "
+ "(even if you want to order by only one field)."),
hint=None,
obj=cls,
- id='E012',
+ id='models.E014',
)
]
@@ -1398,10 +1394,10 @@ def _check_ordering(cls):
except FieldDoesNotExist:
errors.append(
checks.Error(
- '"ordering" pointing to a missing "%s" field.' % field_name,
- hint='Ensure that you did not misspell the field name.',
+ "'ordering' refers to the non-existent field '%s'." % field_name,
+ hint=None,
obj=cls,
- id='E013',
+ id='models.E015',
)
)
return errors
@@ -109,7 +109,7 @@ class TaggedItem(models.Model):
"The GenericForeignKey content type references the non-existent field 'TaggedItem.content_type'.",
hint=None,
obj=TaggedItem.content_object,
- id='contenttypes.E003',
+ id='contenttypes.E002',
)
]
self.assertEqual(errors, expected)
@@ -127,7 +127,7 @@ class Model(models.Model):
"'Model.content_type' is not a ForeignKey.",
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
obj=Model.content_object,
- id='contenttypes.E004',
+ id='contenttypes.E003',
)
]
self.assertEqual(errors, expected)
@@ -145,7 +145,7 @@ class Model(models.Model):
"'Model.content_type' is not a ForeignKey to 'contenttypes.ContentType'.",
hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
obj=Model.content_object,
- id='contenttypes.E005',
+ id='contenttypes.E004',
)
]
self.assertEqual(errors, expected)
@@ -162,7 +162,7 @@ class TaggedItem(models.Model):
"The GenericForeignKey object ID references the non-existent field 'object_id'.",
hint=None,
obj=TaggedItem.content_object,
- id='contenttypes.E002',
+ id='contenttypes.E001',
)
]
self.assertEqual(errors, expected)
@@ -180,7 +180,7 @@ class Model(models.Model):
'Field names must not end with an underscore.',
hint=None,
obj=Model.content_object_,
- id='contenttypes.E001',
+ id='fields.E001',
)
]
self.assertEqual(errors, expected)
@@ -265,7 +265,7 @@ class Bookmark(models.Model):
errors = Bookmark.tags.field.check()
expected = [
- checks.Warning(
+ checks.Error(
("The GenericRelation defines a relation with the model "
"'contenttypes_tests.TaggedItem', but that model does not have a "
"GenericForeignKey."),
Oops, something went wrong.

0 comments on commit bc4dc6e

Please sign in to comment.