0👍
You can use cursor connection for direct execute SQL query.
from django.db import connection
def my_query(self):
with connection.cursor() as cursor:
cursor.execute("UPDATE bar SET foo = 1 WHERE baz = %s", [self.baz])
cursor.execute("SELECT foo FROM bar WHERE baz = %s", [self.baz])
row = cursor.fetchall()
return row
👤Abhi
- [Answered ]-Adding custom_password field to UserSerializer without registering it to User model in Django REST API
- [Answered ]-Live (long-polling) connection to Django, via Nginx (or apache) – reducing the number of queries
- [Answered ]-Django custom filter look up template variable
Source:stackexchange.com