Opened 3 years ago

Closed 2 years ago

Last modified 22 months ago

#18491 closed Bug (fixed)

When deleting a proxy model, the admin does not show warning about cascade delete for object with foreign key on the proxied model

Reported by: bdauvergne@… Owned by: gszczepanczyk
Component: contrib.admin Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Suppose this

class A(Model):
   pass

class ProxyA(A):
   class Meta:
      proxy = True

class B(Model):
   a = ForeignKey(A)

If you expose ProxyA in the admin/ and try to delete an instance which has linked B objects, there will be no warning about the cascading delete.

Change History (11)

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Here's the history of bugs related to deletion of proxy models: #18083, #16128, #12208, #11116.

comment:2 Changed 3 years ago by akaariai

  • Triage Stage changed from Unreviewed to Accepted

I have verified this in HEAD.

comment:3 Changed 2 years ago by gszczepanczyk

  • Owner changed from nobody to gszczepanczyk
  • Status changed from new to assigned

comment:4 Changed 2 years ago by gszczepanczyk

  • Has patch set

I have added pull request with fix: https://github.com/django/django/pull/774

comment:5 Changed 2 years ago by chomik

  • Triage Stage changed from Accepted to Ready for checkin

PR 774 seems ok for me.

comment:6 Changed 2 years ago by gszczepanczyk

I have pushed recommended solution.

comment:7 Changed 2 years ago by Honza Kral <honza.kral@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 2b48fcc607010065c0f8107baf669dd41b164f3c:

Fixed #18491 -- deleting a proxy doesn't show warning about cascade deletes

comment:8 Changed 22 months ago by timo

Fixing this seems to have introduced another regression, see #20777. We may revert this fix if we can't come up with a solution for that.

comment:9 Changed 22 months ago by Tim Graham <timograham@…>

In c769c266017c9a527444f8f026c7a76b394d0412:

[1.6.x] Revert "Fixed #18491 -- deleting a proxy doesn't show warning about cascade deletes"

This reverts commit 2b48fcc607010065c0f8107baf669dd41b164f3c.

It introduced a regression (#20777) which we can't easily fix in 1.6.

comment:10 Changed 22 months ago by timo

Fix has been reverted in 1.6.x, but will remain in master and removed (but fixed via a new change) in https://github.com/django/django/pull/1478

comment:11 Changed 22 months ago by akaariai

Fixed again in 3844089edc43ff29aab5bac82a0eecab23d8d14a - the fix isn't in 1.6.x, only master.

Note: See TracTickets for help on using tickets.
Back to Top