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)
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.As it stands it is a usage issue. I don't see it as really common enough to justify a warning in docs.