Ticket #3323: patch-foreignkey-attributeerror.diff
File patch-foreignkey-attributeerror.diff, 2.9 KB (added by , 17 years ago) |
---|
-
django/db/models/options.py
152 152 rel_objs = [] 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 158 158 return rel_objs … … 186 186 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(): 192 192 self._all_related_many_to_many_objects = rel_objs -
django/core/management/validation.py
70 70 # Check to see if the related field will clash with any 71 71 # existing fields, m2m fields, m2m related objects or related objects 72 72 if f.rel: 73 rel_opts = f.rel.to._meta74 73 if f.rel.to not in models.get_models(): 75 e.add(opts, "'%s' has relation with model %s, which has not been installed" % (f.name, rel_opts.object_name)) 74 e.add(opts, "'%s' has relation with model %s, which has not been installed" % (f.name, f.rel.to)) 75 continue 76 76 77 rel_opts = f.rel.to._meta 77 78 rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() 78 79 rel_query_name = f.related_query_name() 79 80 for r in rel_opts.fields: … … 101 102 for i, f in enumerate(opts.many_to_many): 102 103 # Check to see if the related m2m field will clash with any 103 104 # existing fields, m2m fields, m2m related objects or related objects 104 rel_opts = f.rel.to._meta105 105 if f.rel.to not in models.get_models(): 106 e.add(opts, "'%s' has m2m relation with model %s, which has not been installed" % (f.name, rel_opts.object_name)) 106 e.add(opts, "'%s' has m2m relation with model %s, which has not been installed" % (f.name, f.rel.to)) 107 continue 107 108 109 rel_opts = f.rel.to._meta 108 110 rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() 109 111 rel_query_name = f.related_query_name() 110 112 # If rel_name is none, there is no reverse accessor.