from django.db import models
# Create your models here.
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField()
上面是orm类
下面是python manage.py makemigrations mosel_app创建得0001
# Generated by Django 2.2.6 on 2019-10-25 02:46
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Question',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('question_text', models.CharField(max_length=200)),
('pub_date', models.DateTimeField()),
],
),
]
但是在cmd运行python manage.py migrate 出现下面错误
Operations to perform:
Apply all migrations: admin, auth, contenttypes, model_app, sessions
Running migrations:
Traceback (most recent call last):
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\backends\utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\backends\mysql\base.py", line 71, in execute
return self.cursor.execute(query, args)
File "D:\python_virtualEnv\django_env\lib\site-packages\MySQLdb\cursors.py", line 209, in execute
res = self._query(query)
File "D:\python_virtualEnv\django_env\lib\site-packages\MySQLdb\cursors.py", line 315, in _query
db.query(q)
File "D:\python_virtualEnv\django_env\lib\site-packages\MySQLdb\connections.py", line 226, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\migrations\recorder.py", line 67, in ensure_schema
editor.create_model(self.Migration)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\backends\base\schema.py", line 307, in create_model
self.execute(sql, params or None)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\backends\base\schema.py", line 137, in execute
cursor.execute(sql, params)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\backends\utils.py", line 99, in execute
return super().execute(sql, params)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\backends\utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\backends\utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\backends\mysql\base.py", line 71, in execute
return self.cursor.execute(query, args)
File "D:\python_virtualEnv\django_env\lib\site-packages\MySQLdb\cursors.py", line 209, in execute
res = self._query(query)
File "D:\python_virtualEnv\django_env\lib\site-packages\MySQLdb\cursors.py", line 315, in _query
db.query(q)
File "D:\python_virtualEnv\django_env\lib\site-packages\MySQLdb\connections.py", line 226, in query
_mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1")
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "D:\python_virtualEnv\django_env\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "D:\python_virtualEnv\django_env\lib\site-packages\django\core\management\commands\migrate.py", line 234, in handle
fake_initial=fake_initial,
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\migrations\executor.py", line 91, in migrate
self.recorder.ensure_schema()
File "D:\python_virtualEnv\django_env\lib\site-packages\django\db\migrations\recorder.py", line 69, in ensure_schema
raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1"))
提示我一个语法错误,什么NOT NULL,这是什么意思???