Opened 3 years ago

Closed 3 years ago

#33550 closed Uncategorized (invalid)

Unexpected on_delete behavior in apps that have been removed from INSTALLED_APPS

Reported by: Tobias Bengfort Owned by: nobody
Component: Documentation Version: 4.0
Severity: Normal Keywords: INSTALLED_APPS ForeignKey on_delete
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If I remove an app from INSTALLED_APPS that contains models with ForeignKeys to other apps, the python-level on_delete is removed but the database level foreign key constraint still exists. The residual ForeignKeys can then block the deletion of other content.

I guess the proper way to deal with this is to drop all tables belonging to the removed app. There should be a warning about this in the documentation.

An alternative approach could be to allow database-level on_delete (see 21961)

Change History (1)

comment:1 by Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed

Thanks for the ticket, however I don't see anything unexpected in the current behavior. You removed an app from INSTALLED_APPS without reverting all applied migrations for that app, so tables, relations, etc. still exist in the database. There is nothing Django can do automatically in this case.

There should be a warning about this in the documentation.

As it stands it is a usage issue. I don't see it as really common enough to justify a warning in docs.

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