Django on_delete=models.CASCADE has no effect at SQL level Django on_delete=models.CASCADE has no effect at SQL level mysql mysql

Django on_delete=models.CASCADE has no effect at SQL level


From the docs (emphasis mine):

ForeignKey.on_delete

When an object referenced by a ForeignKey is deleted, Django will emulate the behavior of the SQL constraint specified by the on_delete argument.

Django does not actually set an ON DELETE clause in the database. If you need one, you can add one manually using a RunSQL operation. Be sure to use the same index name, or keep the original index, or you might run into errors later on.