Changeset 8488
- Timestamp:
- 08/23/08 11:56:41 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/validation.py
r8442 r8488 100 100 e.add(opts, "Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) 101 101 102 seen_intermediary_signatures = [] 102 seen_intermediary_signatures = [] 103 103 for i, f in enumerate(opts.local_many_to_many): 104 104 # Check to see if the related m2m field will clash with any … … 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'): … … 153 158 else: 154 159 e.add(opts, "'%s' specifies an m2m relation through model %s, which has not been installed" % (f.name, f.rel.through)) 155 160 156 161 rel_opts = f.rel.to._meta 157 162 rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() django/trunk/tests/modeltests/invalid_models/models.py
r8442 r8488 111 111 rel1 = models.ForeignKey("Rel1") 112 112 rel2 = models.ManyToManyField("Rel2") 113 113 114 114 class MissingManualM2MModel(models.Model): 115 115 name = models.CharField(max_length=5) 116 116 missing_m2m = models.ManyToManyField(Model, through="MissingM2MModel") 117 117 118 118 class Person(models.Model): 119 119 name = models.CharField(max_length=5) … … 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. … … 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 """
