Always set explicit ForeignKey.on_delete values.
Review Request #10267 — Created Oct. 23, 2018 and submitted — Latest diff uploaded
Django 2.0 requires
ForeignKey
instances to haveon_delete
set.
Prior to 2.0, these defaulted toCASCADE
, which would delete the
owning model if the object on the other end of the relation was deleted
within Django's ORM. In 2.0, they apparently wanted this to be explicit,
and 1.11 pretty heavily announces deprecation warnings in preparation
for that.This change adds explicit
on_delete
settings for eachForeignKey
in
the codebase, and updates the creation ofForeignKey
s from a database
signature to provide a suitable default if not found in the signature.
Unit tests pass on Django 1.6 through 1.11, and on 2.1 with other
pending changes.