Login

Snippets by psagers

Snippet List

Clear nullable foreign keys on delete

Django 1.0 is apparently hard-coded for cascading deletes. I find that I often have nullable foreign keys on models whose records must not be deleted along with those they refer to. I override Model.delete() in an intermediate base class and execute this method to clear out all nullable foreign keys before allowing a delete to proceed.

  • model
  • delete
  • cascade
Read More

psagers has posted 1 snippet.