Skip to content

Instantly share code, notes, and snippets.

@charettes
Created February 2, 2016 16:23
Show Gist options
  • Select an option

  • Save charettes/e4e650eecaf3f5fc58d3 to your computer and use it in GitHub Desktop.

Select an option

Save charettes/e4e650eecaf3f5fc58d3 to your computer and use it in GitHub Desktop.

Revisions

  1. charettes created this gist Feb 2, 2016.
    7 changes: 7 additions & 0 deletions allow_migrate_cascade.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    from django.db import router
    from django.db.models import deletion

    def ALLOW_MIGRATE_CASCADE(collector, field, sub_objs, using):
    opts = sub_objs[0]._meta
    if router.allow_migrate(using, opts.app_label, opts.model_name):
    deletion.CASCADE(collector, field, sub_objs, using)