[Django] #29087: Impossible to delete pending new inline in admin when invalid (delete button missing)

31 views
Skip to first unread message

Django

unread,
Jan 29, 2018, 11:21:58 PM1/29/18
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-----------------------------------------+------------------------
Reporter: Owen Heisler | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-----------------------------------------+------------------------
When adding a new inline record in the Django Admin, it is impossible to
delete the record if it has had a validation error. This is the most
evident to the user if he/she accidentally attempts to use the wrong
inline for some data. For example, if a ContactAdmin has both PhoneInline
and EmailInline, the user may accidentally enter a phone number in an
EmailInline record. When attempting to submit the changes, a validation
error is raised. Seeing the problem, the user would now like to just
delete the new record that is pending. However, at this point there is no
'''Delete''' button. Thus the user is forced to either (a) reload the
change page, discarding any other unrelated pending changes on the page;
or (b) change the data to make it valid, click '''Save and continue
editing''', and then delete the offending record before finally saving the
changes again.

==== Test code

Consider the following code, where the Django Admin provides access to a
'''Groups''' page with a '''Persons''' inline.

models.py:
{{{#!python
from django.db import models

class Group(models.Model):
name = models.CharField(max_length=30)

class Person(models.Model):
group = models.ForeignKey(Group, on_delete=models.CASCADE)
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
}}}

admin.py:
{{{#!python
from django.contrib import admin
from .models import *

class PersonInline(admin.StackedInline):
model = Person
extra = 0

@admin.register(Group)
class GroupAdmin(admin.ModelAdmin):
inlines = [PersonInline]
}}}

==== Steps to reproduce

1. Go to the Group add page (for example,
<http://localhost:8000/admin/myapp/group/add/>). Enter a Group name, add a
Person with first_name and last_name, and click '''Save and continue
editing'''.
2. Change the Group name. Add a second Person for the group, but enter a
first_name only. A delete button ({{{X}}} icon) is available to discard
the pending record: [[Image(https://s13.postimg.org/6wv1azzyv/image.png)]]
3. Click '''SAVE'''. There will be a validation error, as expected,
because last_name is not provided. However, the '''Delete''' button is
missing: [[Image(https://s13.postimg.org/3q0hrduyf/image.png)]]
4. '''The user is now forced to either (a) fix the validation error or (b)
reload the page, discarding all unrelated changes on the page. It is not
possible for the user to fix the validation error by simply
canceling/deleting the pending new record.'''

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

Django

unread,
Feb 3, 2018, 5:49:44 PM2/3/18
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------+------------------------------------

Reporter: Owen Heisler | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


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

Django

unread,
Feb 18, 2018, 5:59:51 AM2/18/18
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------+-----------------------------------------
Reporter: Owen Heisler | Owner: Vitor Freitas
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+-----------------------------------------
Changes (by Vitor Freitas):

* status: new => assigned
* owner: nobody => Vitor Freitas


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

Django

unread,
Jun 7, 2019, 10:22:27 AM6/7/19
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------+------------------------------------
Reporter: Owen Heisler | Owner: (none)

Type: Bug | Status: new
Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Changes (by Vitor Freitas):

* owner: Vitor Freitas => (none)
* status: assigned => new


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

Django

unread,
Jun 7, 2019, 12:42:10 PM6/7/19
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------+------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Changes (by frnhr):

* status: new => assigned

* owner: (none) => frnhr


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

Django

unread,
Jun 22, 2019, 5:04:21 PM6/22/19
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------+------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Changes (by frnhr):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/11504

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

Django

unread,
Aug 30, 2019, 3:30:58 PM8/30/19
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------+------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Description changed by frnhr:

Old description:

New description:

==== Test code

==== Steps to reproduce

----

==== It is actually worse than that...

Another cause of validation errors can be uniqueness constraints. These
errors can be difficult to fix and sometimes actually cannot be fixed. So
it is totally possible that because of a validation error the user is
**forced to reload the page**, there is no other choice.

Building on the models above, here is an example of a validation error
that can be unsalvageable for users without the `create` permission for
groups. New `Council` model is added, a foreign key from `Person` to
`Council` is created and also a constraint with `unique_together =
('council', 'group')` is set.

[[Image(https://i.ibb.co/41gpvgS/Screenshot-2019-08-30-at-21-08-13.png)]]

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:6>

Django

unread,
Aug 30, 2019, 4:04:44 PM8/30/19
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------+------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Description changed by frnhr:

Old description:

> When adding a new inline record in the Django Admin, it is impossible to

>


> ----
>
> ==== It is actually worse than that...
>
> Another cause of validation errors can be uniqueness constraints. These
> errors can be difficult to fix and sometimes actually cannot be fixed. So
> it is totally possible that because of a validation error the user is
> **forced to reload the page**, there is no other choice.
>
> Building on the models above, here is an example of a validation error
> that can be unsalvageable for users without the `create` permission for
> groups. New `Council` model is added, a foreign key from `Person` to
> `Council` is created and also a constraint with `unique_together =
> ('council', 'group')` is set.
>
> [[Image(https://i.ibb.co/41gpvgS/Screenshot-2019-08-30-at-21-08-13.png)]]

New description:

==== Test code

==== Steps to reproduce

----

==== It is actually worse than that...

Another cause of validation errors can be uniqueness constraints. These
errors can be difficult to fix and sometimes actually cannot be fixed. So
it is totally possible that because of a validation error the user is
**forced to reload the page**, there is no other choice.

Building on the models above, here is an example of a validation error
that can be unsalvageable for users without the `create` permission for
groups. New `Council` model is added, a foreign key from `Person` to
`Council` is created and also a constraint with `unique_together =
('council', 'group')` is set.

[[Image(https://i.ibb.co/K2ndRGT/Screenshot-2019-08-30-at-21-08-13.png)]]

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:7>

Django

unread,
Oct 2, 2019, 5:45:19 AM10/2/19
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------+------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.0

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

Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 0 => 1


Comment:

Fix should address `TabularInline` too. (This has the same issue.) Also,
the PR includes a significant refactoring, which should be in a separate
commit.
But other than that, looks goods. (Works 🙂)

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:8>

Django

unread,
Oct 2, 2019, 11:13:34 AM10/2/19
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------+------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+------------------------------------
Changes (by frnhr):

* needs_better_patch: 1 => 0


Comment:

PR edited

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:9>

Django

unread,
Oct 3, 2019, 11:06:32 AM10/3/19
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------------+-------------------------------------

Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


Comment:

PR is ready to go.

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:10>

Django

unread,
Oct 25, 2019, 7:29:25 AM10/25/19
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------------+-------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton@…>):

In [changeset:"6ea3aadd17f937e69d121e3ae1a415a435e3267d" 6ea3aad]:
{{{
#!CommitTicketReference repository=""
revision="6ea3aadd17f937e69d121e3ae1a415a435e3267d"
Refs #29087 -- Refactored admin inlines.js.

Split logic into separate functions to clarify and allow reuse.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:11>

Django

unread,
Oct 25, 2019, 7:29:25 AM10/25/19
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------------+-------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson <carlton@…>):

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


Comment:

In [changeset:"24e540fbd71bd2b0843e751bde61ad0052a811b3" 24e540f]:
{{{
#!CommitTicketReference repository=""
revision="24e540fbd71bd2b0843e751bde61ad0052a811b3"
Fixed #29087 -- Added delete buttons for unsaved admin inlines on
validation error.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:12>

Django

unread,
Jan 27, 2021, 2:44:54 AM1/27/21
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------------+-------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton@…>):

In [changeset:"f4272d000af598018247fe9687dac0fd02a29a7c" f4272d00]:
{{{
#!CommitTicketReference repository=""
revision="f4272d000af598018247fe9687dac0fd02a29a7c"
Fixed #32348, Refs #29087 -- Corrected tutorial for updated deleting
inlines UI.

Updated tutorial to match change in
24e540fbd71bd2b0843e751bde61ad0052a811b3
allowing deletion of original extra inlines.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:13>

Django

unread,
Jan 27, 2021, 2:48:12 AM1/27/21
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------------+-------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"4dbbe3747955cbecbf3668c93a0c885562f063ac" 4dbbe37]:
{{{
#!CommitTicketReference repository=""
revision="4dbbe3747955cbecbf3668c93a0c885562f063ac"
[3.2.x] Fixed #32348, Refs #29087 -- Corrected tutorial for updated
deleting inlines UI.

Updated tutorial to match change in
24e540fbd71bd2b0843e751bde61ad0052a811b3
allowing deletion of original extra inlines.

Backport of f4272d000af598018247fe9687dac0fd02a29a7c from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:14>

Django

unread,
Jan 27, 2021, 2:48:40 AM1/27/21
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------------+-------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"fa203f17591d53178c28b20f9ad337812666445d" fa203f17]:
{{{
#!CommitTicketReference repository=""
revision="fa203f17591d53178c28b20f9ad337812666445d"
[3.1.x] Fixed #32348, Refs #29087 -- Corrected tutorial for updated
deleting inlines UI.

Updated tutorial to match change in
24e540fbd71bd2b0843e751bde61ad0052a811b3
allowing deletion of original extra inlines.

Backport of f4272d000af598018247fe9687dac0fd02a29a7c from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:15>

Django

unread,
May 12, 2021, 10:05:13 AM5/12/21
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------------+-------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: new
Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Matteo Brutti):

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


Comment:

This bug still exists in Django 2.22

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:16>

Django

unread,
May 12, 2021, 10:24:45 AM5/12/21
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------------+-------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

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


Comment:

Please don't reopen closed tickets.

This fix was made as part of Django 3.1 (see
24e540fbd71bd2b0843e751bde61ad0052a811b3)
You'll need to update to that or beyond.

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:17>

Django

unread,
May 12, 2021, 10:43:24 AM5/12/21
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------------+-------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Backit):

Replying to [comment:17 Carlton Gibson]:


> Please don't reopen closed tickets.
>
> This fix was made as part of Django 3.1 (see
24e540fbd71bd2b0843e751bde61ad0052a811b3)
> You'll need to update to that or beyond.

But 2.2 is still supported, so should receive bugfixes, isn'it?

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:18>

Django

unread,
May 12, 2021, 1:58:58 PM5/12/21
to django-...@googlegroups.com
#29087: Impossible to delete pending new inline in admin when invalid (delete
button missing)
-------------------------------------+-------------------------------------
Reporter: Owen Heisler | Owner: frnhr
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:18 Backit]:


> But 2.2 is still supported, so should receive bugfixes, isn'it?

Django 2.2. is in extended support so it receives only security patches.

--
Ticket URL: <https://code.djangoproject.com/ticket/29087#comment:19>

Reply all
Reply to author
Forward
0 new messages