Edited model check messages for grammar and consistency.

This commit is contained in:
Russell Keith-Magee 2014-03-03 15:35:42 +08:00
parent f7587b20da
commit bc4dc6e99c
4 changed files with 117 additions and 125 deletions

View file

@ -67,7 +67,7 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
'Field names must not end with an underscore.',
hint=None,
obj=self,
id='contenttypes.E001',
id='fields.E001',
)
]
else:
@ -82,7 +82,7 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
"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 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
),
hint=None,
obj=self,
id='contenttypes.E003',
id='contenttypes.E002',
)
]
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.",
obj=self,
id='contenttypes.E004',
id='contenttypes.E003',
)
]
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.",
obj=self,
id='contenttypes.E005',
id='contenttypes.E004',
)
]
else:
@ -282,7 +282,7 @@ class GenericRelation(ForeignObject):
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

View file

@ -1078,26 +1078,22 @@ class Model(six.with_metaclass(ModelBase)):
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 @@ class Model(six.with_metaclass(ModelBase)):
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 @@ class Model(six.with_metaclass(ModelBase)):
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 @@ class Model(six.with_metaclass(ModelBase)):
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 @@ class Model(six.with_metaclass(ModelBase)):
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 @@ class Model(six.with_metaclass(ModelBase)):
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,10 +1259,10 @@ class Model(six.with_metaclass(ModelBase)):
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',
)
]
@ -1274,10 +1270,10 @@ class Model(six.with_metaclass(ModelBase)):
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,10 +1289,10 @@ class Model(six.with_metaclass(ModelBase)):
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',
)
]
@ -1304,10 +1300,10 @@ class Model(six.with_metaclass(ModelBase)):
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 @@ class Model(six.with_metaclass(ModelBase)):
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 @@ class Model(six.with_metaclass(ModelBase)):
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 @@ class Model(six.with_metaclass(ModelBase)):
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