def activate_foreign_keys(sender, connection, **kwargs):
 if (connection.vendor == 'sqlite'):
  cursor = connection.cursor()
  cursor.execute('PRAGMA foreign_keys = ON;')

def activate_foreign_keys ( sender , connection , ** kwargs ) : if ( connection . vendor == 'sqlite' ) : cursor = connection . cursor ( ) cursor . execute ( 'PRAGMA foreign_keys = ON;' )
enable integrity constraint with sqlite .