Ticket #12025: t12025_r11366.patch
File t12025_r11366.patch, 2.0 KB (added by , 15 years ago) |
---|
-
django/db/models/options.py
412 412 cache[obj] = parent 413 413 else: 414 414 cache[obj] = model 415 from django.contrib.contenttypes import generic 415 416 for klass in get_models(): 416 417 for f in klass._meta.local_many_to_many: 417 if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta: 418 if f.rel and isinstance(f, generic.GenericRelation) and self == klass._meta: 419 cache[RelatedObject(klass, f.rel.to, f)] = None 420 elif f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta: 418 421 cache[RelatedObject(f.rel.to, klass, f)] = None 419 422 if app_cache_ready(): 420 423 self._related_many_to_many_cache = cache -
django/contrib/admin/util.py
146 146 p = '%s.%s' % (related.opts.app_label, related.opts.get_delete_permission()) 147 147 if not user.has_perm(p): 148 148 perms_needed.add(related.opts.verbose_name) 149 from django.contrib.contenttypes import generic 149 150 for related in opts.get_all_related_many_to_many_objects(): 150 151 has_admin = related.model in admin_site._registry 151 152 if related.opts in opts_seen: … … 156 157 157 158 # related.get_accessor_name() could return None for symmetrical relationships 158 159 if rel_opts_name: 159 rel_objs = getattr(obj, rel_opts_name, None) 160 rel_objs = getattr(obj, rel_opts_name, None) or \ 161 (isinstance(related.field, generic.GenericRelation) and getattr(obj, related.field.verbose_name, None)) 160 162 if rel_objs: 161 163 has_related_objs = True 162 164