I'm trying to force my django project to always use strict sql_mode
. Is there another way than putting the following in manage.py
? It seems overly complicated.
def set_strict_sql_mode(sender, **kwargs):
from django.conf import settings
if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.mysql':
from django.db import connection
cursor = connection.cursor()
cursor.execute('SET session sql_mode=traditional')
from django.core.signals import request_started
request_started.connect(set_strict_sql_mode)