#23857 closed Bug (fixed)
"Save as new" breaks when related inlines are marked to be deleted
Reported by: | Alex Marandon | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.7 |
Severity: | Release blocker | Keywords: | |
Cc: | jonathan.morgan@…, jonathan.morgan.007@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Minimal project that triggers the issue:
# model.py from django.db import models class Author(models.Model): name = models.CharField(max_length=100) def __unicode__(self): return self.name class Book(models.Model): title = models.CharField(max_length=100) authors = models.ManyToManyField(Author) def __unicode__(self): return self.title
# admin.py from django.contrib import admin from .models import Author, Book class AuthorshipInline(admin.TabularInline): model = Book.authors.through @admin.register(Author) class AuthorAdmin(admin.ModelAdmin): inlines = [AuthorshipInline] save_as = True @admin.register(Book) class BookAdmin(admin.ModelAdmin): inlines = [AuthorshipInline] save_as = True
How to reproduce the problem using the admin:
- create two authors
- create a book with those two authors
- edit the book
- click the check box in the "Delete?" column for one of the authors
- click "Save as new"
Tail of the stack trace:
File "/home/synext/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/models/deletion.py" in collect 168. reverse_dependency=reverse_dependency) File "/home/synext/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/models/deletion.py" in add 85. if obj not in instances: File "/home/synext/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/models/base.py" in __hash__ 485. raise TypeError("Model instances without primary key value are unhashable") Exception Type: TypeError at /admin/myapp/book/1/ Exception Value: Model instances without primary key value are unhashable
Change History (5)
comment:1 by , 10 years ago
Cc: | added |
---|
comment:2 by , 10 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I could reproduce this by adding
save_as=True
toPollAdmin
from the tutorial and then repeating the steps above. It appears to be a regression in 1.7, probably due to 6af05e7a0f0e4604d6a67899acaa99d73ec0dfaa.