[Django] #23857: "Save as new" breaks when related inlines are marked to be deleted

14 views
Skip to first unread message

Django

unread,
Nov 17, 2014, 9:07:42 AM11/17/14
to django-...@googlegroups.com
#23857: "Save as new" breaks when related inlines are marked to be deleted
-------------------------------+--------------------
Reporter: amarandon | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Minimal project that triggers the issue:
{{{
#!python
# 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
}}}

{{{
#!python
# 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:

{{{
#!pytb

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
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23857>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 19, 2014, 9:58:01 AM11/19/14
to django-...@googlegroups.com
#23857: "Save as new" breaks when related inlines are marked to be deleted
-------------------------------+--------------------------------------

Reporter: amarandon | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by jonathanmorgan):

* cc: jonathan.morgan.007@… (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/23857#comment:1>

Django

unread,
Nov 24, 2014, 1:16:10 PM11/24/14
to django-...@googlegroups.com
#23857: "Save as new" breaks when related inlines are marked to be deleted
---------------------------------+------------------------------------

Reporter: amarandon | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by timgraham):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

I could reproduce this by adding `save_as=True` to `PollAdmin` from the
tutorial and then repeating the steps above. It appears to be a regression
in 1.7, probably due to 6af05e7a0f0e4604d6a67899acaa99d73ec0dfaa.

--
Ticket URL: <https://code.djangoproject.com/ticket/23857#comment:2>

Django

unread,
Dec 4, 2014, 8:24:53 AM12/4/14
to django-...@googlegroups.com
#23857: "Save as new" breaks when related inlines are marked to be deleted
---------------------------------+------------------------------------

Reporter: amarandon | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by timgraham):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/3682 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/23857#comment:3>

Django

unread,
Dec 12, 2014, 11:49:44 AM12/12/14
to django-...@googlegroups.com
#23857: "Save as new" breaks when related inlines are marked to be deleted
---------------------------------+------------------------------------
Reporter: amarandon | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.7
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"c7a19f42030c15ad3b3475ad9a4854e10733ff74"]:
{{{
#!CommitTicketReference repository=""
revision="c7a19f42030c15ad3b3475ad9a4854e10733ff74"
Fixed #23857 -- Fixed admin crash with "save as new" and deleting inline.

Thanks amarandon for the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23857#comment:4>

Django

unread,
Dec 12, 2014, 12:07:12 PM12/12/14
to django-...@googlegroups.com
#23857: "Save as new" breaks when related inlines are marked to be deleted
---------------------------------+------------------------------------
Reporter: amarandon | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.7

Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"c64286c62b5960387d5e8fc3e28cd37662bda6cb"]:
{{{
#!CommitTicketReference repository=""
revision="c64286c62b5960387d5e8fc3e28cd37662bda6cb"
[1.7.x] Fixed #23857 -- Fixed admin crash with "save as new" and deleting
inline.

Thanks amarandon for the report.

Backport of c7a19f42030c15ad3b3475ad9a4854e10733ff74 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23857#comment:5>

Reply all
Reply to author
Forward
0 new messages