summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-21 01:45:15 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-21 01:45:15 +0000
commit270377cb37e3bbe5f2432cdab94fe955ace099ea (patch)
treedd9855598faa93d2027fdcd50ffeb7bd1d562374
parent7a80b2cc985a40eac6deb8e4e6ec050a8274bc47 (diff)
Fixed #861 -- Model validator now validates unique_together
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1323 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/django/core/management.py b/django/core/management.py
index 6b4f87b000..205cdec3e5 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -677,6 +677,17 @@ def get_validation_errors(outfile):
e.add(rel_opts, "At least one field in %s should have core=True, because it's being edited inline by %s.%s." % (rel_opts.object_name, opts.module_name, opts.object_name))
except StopIteration:
pass
+
+ # Check unique_together.
+ for ut in opts.unique_together:
+ for field_name in ut:
+ try:
+ f = opts.get_field(field_name, many_to_many=True)
+ except meta.FieldDoesNotExist:
+ e.add(opts, '"unique_together" refers to %s, a field that doesn\'t exist. Check your syntax.' % field_name)
+ else:
+ if isinstance(f.rel, meta.ManyToMany):
+ e.add(opts, '"unique_together" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name)
return len(e.errors)
def validate(outfile=sys.stdout):