mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #11702: Catch to_field specifying a non-unique target in validation. Thanks marcosmoyano.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12756 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -80,6 +80,10 @@ def get_validation_errors(outfile, app=None):
|
||||
if isinstance(f.rel.to, (str, unicode)):
|
||||
continue
|
||||
|
||||
# Make sure the related field specified by a ForeignKey is unique
|
||||
if not f.rel.to._meta.get_field(f.rel.field_name).unique:
|
||||
e.add(opts, "Field '%s' under model '%s' must have a unique=True constraint." % (f.rel.field_name, f.rel.to.__name__))
|
||||
|
||||
rel_opts = f.rel.to._meta
|
||||
rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name()
|
||||
rel_query_name = f.related_query_name()
|
||||
|
||||
Reference in New Issue
Block a user