对不起,我不认为我的问题的标题很容易理解,因为我绝对是在LPTHW之后尝试理解django的菜鸟。无论如何,我遵循tutorial设置Django以使用MariaDB。但是不幸的是,当我运行python manage.py 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/2.1/ref/databases/#mysql-sql-mode
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial...Traceback (most recent call last):
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 412, in _query
rowcount = self._do_query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 375, in _do_query
db.query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 276, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1050, "Table 'django_content_type' already exists")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 203, in handle
fake_initial=fake_initial,
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/migrations/executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/migrations/migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/migrations/operations/models.py", line 91, in database_forwards
schema_editor.create_model(model)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 312, in create_model
self.execute(sql, params or None)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 133, in execute
cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 412, in _query
rowcount = self._do_query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 375, in _do_query
db.query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 276, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1050, "Table 'django_content_type' already exists")
期望该错误发生后另一个命令可以运行,
python manage.py createsuperuser
返回了另一个错误块:
You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
Traceback (most recent call last):
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 412, in _query
rowcount = self._do_query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 375, in _do_query
db.query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 276, in query
_mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (1146, "Table 'myproject.auth_user' doesn't exist")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 59, in execute
return super().execute(*args, **options)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 93, in handle
default_username = get_default_username()
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/contrib/auth/management/__init__.py", line 136, in get_default_username
auth_app.User._default_manager.get(username=default_username)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/query.py", line 393, in get
num = len(clone)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/query.py", line 250, in __len__
self._fetch_all()
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/query.py", line 1183, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/query.py", line 54, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1061, in execute_sql
cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 412, in _query
rowcount = self._do_query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 375, in _do_query
db.query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 276, in query
_mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'myproject.auth_user' doesn't exist")
您能帮我解决这个问题吗?