Fixed #2828, a TypeError when deleting objects with m2m relations to self. Thanks, Brian Beck.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4616 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2007-02-26 19:12:31 +00:00
parent cb1ff2af35
commit f3cc581f3a
1 changed files with 6 additions and 3 deletions

View File

@ -461,6 +461,9 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
opts_seen.append(related.opts)
rel_opts_name = related.get_accessor_name()
has_related_objs = False
# related.get_accessor_name() could return None for symmetrical relationships
if rel_opts_name:
rel_objs = getattr(obj, rel_opts_name, None)
if rel_objs:
has_related_objs = True