Skip to content

How to delete in cascade? #331

Answered by collerek
pawamoy asked this question in Q&A
Sep 1, 2021 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

Hmm maybe I missed that in the docs, you can pass ondelete and onupdate in ForeignKey like:

source: Optional[DataSource] = ormar.ForeignKey(DataSource, ondelete="CASCADE")

If you want to cascades the delete then use.. CASCADE :)
Those options are passed to sqlalchemy so you can check available options there.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@pawamoy
Comment options

@collerek
Comment options

Answer selected by pawamoy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants