Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
Django - What happens when you delete an entity in a table that has a foreign key ManyToMany relationship to another?

I've noticed that Django doesn't let you set the on_delete parameter for ManyToManyField. This made me curious what happens if you delete an entity in a ManyToMany relationship? So for example, let's say we have Book, which has a ManyToMany relationship to Author. Let's say that a book A has 3 authors: "Tom Lam", "Lam Tom" and "Britney Britney". Then let's say "Britney Britney" gets deleted from the Author table. Does "Britney Britney" get removed from the ManyToMany relationship with Book? Does an exception get thrown when trying to delete "Britney Britney?" What does Django do in the case that an entity is deleted when it exists in a ManyToMany relationship?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If "Britney Britney" is deleted from the Author table, "Britney Britney" is also removed from the book authors (this also applies in reverse). Django does not throw an exception, simply the deleted instance will no longer be accessible through the many-to-many relationship.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!