Support for PROTECT on foreign keys
See original GitHub issueAre there plans to support on_delete=django.db.models.PROTECT
in the admin? Right now ProtectedError
is not caught.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:6
- Comments:17 (13 by maintainers)
Top Results From Across the Web
Foreign Key Constraint | CockroachDB Docs
The `FOREIGN KEY` constraint specifies a column can contain only values exactly matching existing values from the column it references.
Read more >Primary and Foreign Key Constraints - SQL Server
Primary keys and foreign keys are two types of constraints that can be used to enforce data integrity in SQL Server tables.
Read more >SQLite Foreign Key Support
SQL foreign key constraints are used to enforce "exists" relationships between tables. For example, consider a database schema created using the ...
Read more >Foreign keys | Cloud Spanner
Foreign keys cannot be created on columns with the allow_commit_timestamp=true option. Array columns are not supported. JSON columns are not supported. A ...
Read more >Foreign keys and associations - GitLab Docs
Add a foreign key here on column posts.user_id . This ensures that data consistency is enforced on database level. Foreign keys also mean...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately the solution @pySilver posted works only for pages (that have the
before_delete_page
hook). It isn’t applicable when deleting images, documents or whatever else that is used needs to be deleted.What I propose instead is to use the following middleware:
Just add it to the end of your
MIDDLEWARE
list. If aProtectedError
is thrown it will catch it and add a proper message to the view gracefully handling the excception. I think that this middleware needs to be a part of the wagtail default installation or at least mentioned somewhere in the docs so that people can use it if they want it.@spapas I just mean that as workaround this middleware is fine (which is great since there is nothing else available right now), but as part of wagtail it should be done on a lower level.