Changeset 6835
- Timestamp:
- 12/02/07 12:10:07 (7 months ago)
- Files:
-
- django/trunk/django/core/management/validation.py (modified) (2 diffs)
- django/trunk/django/db/models/options.py (modified) (2 diffs)
- django/trunk/tests/modeltests/invalid_models/models.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/validation.py
r6590 r6835 73 73 # existing fields, m2m fields, m2m related objects or related objects 74 74 if f.rel: 75 if f.rel.to not in models.get_models(): 76 e.add(opts, "'%s' has relation with model %s, which has not been installed" % (f.name, f.rel.to)) 77 # it is a string and we could not find the model it refers to 78 # so skip the next section 79 if isinstance(f.rel.to, (str, unicode)): 80 continue 81 75 82 rel_opts = f.rel.to._meta 76 if f.rel.to not in models.get_models():77 e.add(opts, "'%s' has relation with model %s, which has not been installed" % (f.name, rel_opts.object_name))78 79 83 rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() 80 84 rel_query_name = f.related_query_name() … … 104 108 # Check to see if the related m2m field will clash with any 105 109 # existing fields, m2m fields, m2m related objects or related objects 110 if f.rel.to not in models.get_models(): 111 e.add(opts, "'%s' has m2m relation with model %s, which has not been installed" % (f.name, f.rel.to)) 112 # it is a string and we could not find the model it refers to 113 # so skip the next section 114 if isinstance(f.rel.to, (str, unicode)): 115 continue 116 106 117 rel_opts = f.rel.to._meta 107 if f.rel.to not in models.get_models():108 e.add(opts, "'%s' has m2m relation with model %s, which has not been installed" % (f.name, rel_opts.object_name))109 110 118 rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() 111 119 rel_query_name = f.related_query_name() django/trunk/django/db/models/options.py
r6801 r6835 153 153 for klass in get_models(): 154 154 for f in klass._meta.fields: 155 if f.rel and self == f.rel.to._meta:155 if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta: 156 156 rel_objs.append(RelatedObject(f.rel.to, klass, f)) 157 157 self._all_related_objects = rel_objs … … 187 187 for klass in get_models(): 188 188 for f in klass._meta.many_to_many: 189 if f.rel and self == f.rel.to._meta:189 if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta: 190 190 rel_objs.append(RelatedObject(f.rel.to, klass, f)) 191 191 if app_cache_ready(): django/trunk/tests/modeltests/invalid_models/models.py
r6590 r6835 108 108 colour = models.CharField(max_length=5) 109 109 model = models.ForeignKey(Model) 110 111 class MissingRelations(models.Model): 112 rel1 = models.ForeignKey("Rel1") 113 rel2 = models.ManyToManyField("Rel2") 110 114 111 115 model_errors = """invalid_models.fielderrors: "charfield": CharFields require a "max_length" attribute. … … 192 196 invalid_models.selfclashm2m: Reverse query name for m2m field 'm2m_3' clashes with field 'SelfClashM2M.selfclashm2m'. Add a related_name argument to the definition for 'm2m_3'. 193 197 invalid_models.selfclashm2m: Reverse query name for m2m field 'm2m_4' clashes with field 'SelfClashM2M.selfclashm2m'. Add a related_name argument to the definition for 'm2m_4'. 198 invalid_models.missingrelations: 'rel2' has m2m relation with model Rel2, which has not been installed 199 invalid_models.missingrelations: 'rel1' has relation with model Rel1, which has not been installed 194 200 """
