mirror of https://github.com/django/django.git
new-admin and trunk: Normalized spacing differences in bin/validate.py between trunk and new-admin
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1420 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
baba996254
commit
c60e323e5d
|
@ -13,19 +13,27 @@ def validate_class(klass):
|
||||||
# Fields.
|
# Fields.
|
||||||
for f in opts.fields:
|
for f in opts.fields:
|
||||||
if isinstance(f, meta.ManyToManyField):
|
if isinstance(f, meta.ManyToManyField):
|
||||||
assert isinstance(f.rel, meta.ManyToMany), "ManyToManyField %s should have 'rel' set to a ManyToMany instance." % f.name
|
assert isinstance(f.rel, meta.ManyToMany), \
|
||||||
|
"ManyToManyField %s should have 'rel' set to a ManyToMany instance." % f.name
|
||||||
# Inline related objects.
|
# Inline related objects.
|
||||||
for rel_opts, rel_field in opts.get_inline_related_objects():
|
for rel_opts, rel_field in opts.get_inline_related_objects():
|
||||||
assert len([f for f in rel_opts.fields if f.core]) > 0, "At least one field in %s should have core=True, because it's being edited inline by %s." % (rel_opts.object_name, opts.object_name)
|
assert len([f for f in rel_opts.fields if f.core]) > 0, \
|
||||||
|
"At least one field in %s should have core=True, because it's being edited inline by %s." % \
|
||||||
|
(rel_opts.object_name, opts.object_name)
|
||||||
# All related objects.
|
# All related objects.
|
||||||
related_apps_seen = []
|
related_apps_seen = []
|
||||||
for rel_opts, rel_field in opts.get_all_related_objects():
|
for rel_opts, rel_field in opts.get_all_related_objects():
|
||||||
if rel_opts in related_apps_seen:
|
if rel_opts in related_apps_seen:
|
||||||
assert rel_field.rel.related_name is not None, "Relationship in field %s.%s needs to set 'related_name' because more than one %s object is referenced in %s." % (rel_opts.object_name, rel_field.name, opts.object_name, rel_opts.object_name)
|
assert rel_field.rel.related_name is not None, \
|
||||||
|
"Relationship in field %s.%s needs to set 'related_name' because more than one" \
|
||||||
|
" %s object is referenced in %s." % \
|
||||||
|
(rel_opts.object_name, rel_field.name, opts.object_name, rel_opts.object_name)
|
||||||
related_apps_seen.append(rel_opts)
|
related_apps_seen.append(rel_opts)
|
||||||
# Etc.
|
# Etc.
|
||||||
if opts.admin is not None:
|
if opts.admin is not None:
|
||||||
assert opts.admin.ordering or opts.ordering, "%s needs to set 'ordering' on either its 'admin' or its model, because it has 'admin' set." % opts.object_name
|
assert opts.admin.ordering or opts.ordering, \
|
||||||
|
"%s needs to set 'ordering' on either its 'admin' or its model," \
|
||||||
|
" because it has 'admin' set." % opts.object_name
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
|
|
Loading…
Reference in New Issue