Fixed #2199: deleting objects with generic foreign keys in the admin now works. Thanks, Jay Parlar

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3194 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2006-06-22 18:44:06 +00:00
parent 10229c4a1e
commit bc2d8cdbc6
1 changed files with 16 additions and 12 deletions

View File

@ -462,8 +462,12 @@ 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
for sub_obj in getattr(obj, rel_opts_name).all():
rel_objs = getattr(obj, rel_opts_name, None)
if rel_objs:
has_related_objs = True
if has_related_objs:
for sub_obj in rel_objs.all():
if related.field.rel.edit_inline or not related.opts.admin:
# Don't display link to edit, because it either has no
# admin or is edited inline.