title: How can I temporarily disable a foreign key constraint in MySQL?
body: <p>Is it possible to temporarily disable constraints in MySQL?</p>
  <p>I have two Django models, each with a foreign key to the other one. Deleting instances of a model returns an error because of the foreign key constraint:</p>
  <pre><code>cursor.execute(&quot;DELETE FROM myapp_item WHERE n = %s&quot;, n)
  transaction.commit_unless_managed()  #a foreign key constraint fails here
  
  cursor.execute(&quot;DELETE FROM myapp_style WHERE n = %s&quot;, n)
  transaction.commit_unless_managed()
  </code></pre>
  <p>Is it possible to temporarily disable constraints and delete anyway?</p>