Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #861 -- Model validator now validates unique_together

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 7a80b2c commit 270377cb37e3bbe5f2432cdab94fe955ace099ea @adrianholovaty adrianholovaty committed
Showing with 11 additions and 0 deletions.
  1. +11 −0 django/core/
11 django/core/
@@ -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:
+ # 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.' %
return len(e.errors)
def validate(outfile=sys.stdout):

0 comments on commit 270377c

Please sign in to comment.
Something went wrong with that request. Please try again.