diff --git a/django/core/management/validation.py b/django/core/management/validation.py
index 1dc7620..08749cc 100644
a
|
b
|
def get_validation_errors(outfile, app=None):
|
110 | 110 | # so skip the next section |
111 | 111 | if isinstance(f.rel.to, (str, unicode)): |
112 | 112 | continue |
| 113 | |
| 114 | # Check that the field is not set to unique. ManyToManyFields do not support unique. |
| 115 | if f.unique: |
| 116 | e.add(opts, "ManyToManyFields cannot be unique. Remove the unique argument on '%s'." % f.name) |
| 117 | |
113 | 118 | if getattr(f.rel, 'through', None) is not None: |
114 | 119 | if hasattr(f.rel, 'through_model'): |
115 | 120 | from_model, to_model = cls, f.rel.to |
diff --git a/tests/modeltests/invalid_models/models.py b/tests/modeltests/invalid_models/models.py
index c450193..7d83274 100644
a
|
b
|
class AbstractRelationModel(models.Model):
|
177 | 177 | fk1 = models.ForeignKey('AbstractModel') |
178 | 178 | fk2 = models.ManyToManyField('AbstractModel') |
179 | 179 | |
| 180 | class UniqueM2M(models.Model): |
| 181 | """ Model to test for unique ManyToManyFields, which are invalid. """ |
| 182 | unique_people = models.ManyToManyField( Person, unique=True ) |
| 183 | |
180 | 184 | model_errors = """invalid_models.fielderrors: "charfield": CharFields require a "max_length" attribute. |
181 | 185 | invalid_models.fielderrors: "decimalfield": DecimalFields require a "decimal_places" attribute. |
182 | 186 | invalid_models.fielderrors: "decimalfield": DecimalFields require a "max_digits" attribute. |
… |
… |
invalid_models.personselfrefm2m: Intermediary model RelationshipTripleFK has mor
|
271 | 275 | invalid_models.personselfrefm2mexplicit: Many-to-many fields with intermediate tables cannot be symmetrical. |
272 | 276 | invalid_models.abstractrelationmodel: 'fk1' has a relation with model AbstractModel, which has either not been installed or is abstract. |
273 | 277 | invalid_models.abstractrelationmodel: 'fk2' has an m2m relation with model AbstractModel, which has either not been installed or is abstract. |
| 278 | invalid_models.uniquem2m: ManyToManyFields cannot be unique. Remove the unique argument on 'unique_people'. |
274 | 279 | """ |