2017-02-10 7 views
0

新しいプロジェクトを作成してスーパーユーザーを作成したところです。 models.pyをコード化し、eclipseを使って移行を実行すると、エラーメッセージが表示され、Django管理者には何もありません。Pythonを実行するとMysqlエラーが発生するEclipseを使用してDjangoを移行する

ここにエラーメッセージがあります。

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, sessions 
Running migrations: 
    No migrations to apply. 
Finished "C:\Users\ds\workspace\board\manage.py migrate" execution. 

これは、ここで

from __future__ import unicode_literals 
from django.db import models 
from unittest.util import _MAX_LENGTH 
from pip.cmdoptions import editable 
from django.template.defaultfilters import default 
from datetime import datetime 

# Create your models here. 


class User(models.Model): 
    id = models.CharField(_MAX_LENGTH=10) 
    password = models.CharField(_MAX_LENGTH=10) 
    join_date = models.DateTimeField(editable=False, default=datetime.now()) 


class todo(models.Model): 
    user = models.ForeignKey('id') 
    title = models.TextField 
    content = models.TextField 
    date = models.DateField(editable=False, default=datetime.now()) 
+0

Cool story、bro。どこかに質問がありましたか? https://ericlippert.com/2014/03/05/how-to-debug-small-programs/ – spencer7593

+0

settings.pyから質問にデータベースセクションを追加できますか? –

答えて

1

は、ドキュメントの参照がhttps://docs.djangoproject.com/en/1.11/ref/databases/#mysql-sql-mode

されており、ここでは、この警告および将来のエラーを回避するために、データベース構成の一例である私のmodels.pyです:

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.mysql', 
     'NAME': 'dbname', 
     'USER': 'dbuser', 
     'PASSWORD': 'dbpassword', 
     'HOST': 'localhost', 
     'PORT': '', 
     'OPTIONS': { 
      'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", 
     }, 
    } 
} 
関連する問題