6👍
You can delete your record(s) directly via connection.cursor()
(docs):
from django.db import connection
cursor = connection.cursor()
cursor.execute('DELETE FROM costumer_worker WHERE costumer_ptr_id = %s', [costumer.id])
connection.commit()
But, the thing you’re trying to do looks too simple to write SQL directly, use django ORM instead.
2👍
You may be missing comitting the transcation. Based on your settings, you may need to add :
transaction.commit_unless_managed()
in django 1.4 ( not needed in django 1.5, since default settings are different)
0👍
use this line:
from django.db import connection, transaction
cursor = connection.cursor()
with transaction.commit_on_success():
cursor.execute('DELETE FROM costumer_worker WHERE costumer_ptr_id = %s', [costumer.id])
connection.commit()
- [Django]-Django log errors and traceback in file in production environment
- [Django]-Django rest framework – serializing related object fields to a flat json dict
- [Django]-How to make a Django admin readonly textarea field
Source:stackexchange.com