Closed pc10201 closed 5 years ago
This is similar to joke2k/django-environ#92.
The best place to enable strict mode is in your MySQL server config (whether that be the .cnf file for self-hosted, or via eg the Amazon RDS parameter groups).
Enabling it via the Django DB config is a workaround at best IMO, so I don't think this should be supported in dj-database-url (and this definitely isn't a bug with dj-database-url).
It's worth also noting that strict mode is enabled by default for all of:
For more details, see: http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_sql_mode http://dev.mysql.com/doc/refman/5.6/en/sql-mode.html#sql-mode-strict http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_sql_mode http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict
How can I fix this problem?
WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/1.11/ref/databases/#mysql-sql-mode
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'my_database', 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", }, } }
This isn't a bug in dj-database-url, see @edmorley's comment for specifics.
python manager migrate
System check identified some issues:
WARNINGS: ?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default' HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/1.10/ref/databases/#mysql-sql-mode Operations to perform: Apply all migrations: admin, auth, contenttypes, mysite, sessions Running migrations: Rendering model states... DONE Applying auth.0008_alter_user_username_max_length... OK