from django.db.backends.signals import connection_created

def activate_foreign_keys(sender, connection, **kwargs):
    """Enable integrity constraint with sqlite."""
if connection.vendor == 'sqlite':
    cursor = connection.cursor()
cursor.execute('PRAGMA foreign_keys = ON;')
How to make ON DELETE CASCADE work in sqlite 3.7.4?