jazzband / dj-database-url

Use Database URLs in your Django Application.
https://pypi.org/project/dj-database-url/
BSD 3-Clause "New" or "Revised" License
1.49k stars 205 forks source link

django 1.10 warning #71

Closed pc10201 closed 5 years ago

pc10201 commented 8 years ago

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

edmorley commented 8 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).

edmorley commented 8 years ago

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

Allan-Nava commented 6 years ago

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
rhigonet commented 6 years ago

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'my_database', 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", }, } }

jacobian commented 5 years ago

This isn't a bug in dj-database-url, see @edmorley's comment for specifics.