Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #1196 -- Admin deletion step no longer assumes related objects …

…have primary key named 'id'. Thanks, oggie rob

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1973 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ceb558c277876c506e8ee45f98f5029667896c9c 1 parent 6e50a2e
@adrianholovaty adrianholovaty authored
Showing with 3 additions and 2 deletions.
  1. +1 −0  AUTHORS
  2. +2 −2 django/contrib/admin/views/main.py
View
1  AUTHORS
@@ -79,6 +79,7 @@ answer newbie questions, and generally made Django that much better:
Robin Munn <http://www.geekforgod.com/>
Nebojša Dorđević
Sam Newman <http://www.magpiebrain.com/>
+ oggie rob <oz.robharvey@gmail.com>
pgross@thoughtworks.com
phaedo <http://phaedo.cx/>
Luke Plant <http://lukeplant.me.uk/>
View
4 django/contrib/admin/views/main.py
@@ -592,7 +592,7 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
else:
# Display a link to the admin page.
nh(deleted_objects, current_depth, ['%s: <a href="../../../../%s/%s/%s/">%s</a>' % \
- (capfirst(related.opts.verbose_name), related.opts.app_label, related.opts.module_name, sub_obj.id, strip_tags(str(sub_obj))), []])
+ (capfirst(related.opts.verbose_name), related.opts.app_label, related.opts.module_name, getattr(sub_obj, related.opts.pk.attname), strip_tags(str(sub_obj))), []])
_get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2)
# If there were related objects, and the user doesn't have
# permission to delete them, add the missing perm to perms_needed.
@@ -618,7 +618,7 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
nh(deleted_objects, current_depth, [
(_('One or more %(fieldname)s in %(name)s:') % {'fieldname': related.field.name, 'name':related.opts.verbose_name}) + \
(' <a href="../../../../%s/%s/%s/">%s</a>' % \
- (related.opts.app_label, related.opts.module_name, sub_obj.id, strip_tags(str(sub_obj)))), []])
+ (related.opts.app_label, related.opts.module_name, getattr(sub_obj, related.opts.pk.attname), strip_tags(str(sub_obj)))), []])
# If there were related objects, and the user doesn't have
# permission to change them, add the missing perm to perms_needed.
if related.opts.admin and has_related_objs:
Please sign in to comment.
Something went wrong with that request. Please try again.