I want to execute an SQL query, when an item gets deleted in the admin interface. In models.py I do this:
from django.db import connection
class LList(models.Model):
item = models.ForeignKey(Item, models.DO_NOTHING)
def delete(self, *args, **kwargs):
cursor = connection.cursor()
cursor.execute('DELETE FROM some_table where item = %d', [self.item.id])
When I turn debugging on I see all the queries executed. It seems the DELETE FROM query is not executed, I only see
(0.000) DELETE FROM `llist` WHERE `llist`.`id` IN (27); args=(27,)
Why is the other DELETE FROM query not executed? How can I fix that?