异常消息:这是什么意思? - django 1.8 python 3.4 - python manage.py makemigrate
exception messages: What does it mean? - django 1.8 python 3.4 - python manage.py makemigrate
这是错误消息:不确定异常消息的含义。另外,运行 本地服务器时我似乎没有收到任何错误。那么以后会不会报错呢?
(proj1) C:\Users\vetri\Google Drive\proj1\src>python manage.py mak
emigrations
No changes detected
(proj1) C:\Users\vetri\Google Drive\proj1\src>python manage.py mig
rate
Operations to perform:
Synchronize unmigrated apps: messages, staticfiles
Apply all migrations: contenttypes, sessions, admin, Index, auth
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying Index.0001_initial...Traceback (most recent call last):
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 62, in execute
return self.cursor.execute(sql)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\sqlite3\base.py", line 316, in execute
return Database.Cursor.execute(self, query)
sqlite3.OperationalError: table "Index_usermanagement" already exists
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\base.py", line 441, in execute
output = self.handle(*args, **options)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\commands\migrate.py", line 221, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\executor.py", line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake, fake_initial=f
ake_initial)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\executor.py", line 147, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\migration.py", line 115, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, projec
t_state)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\operations\models.py", line 59, in database_forwards
schema_editor.create_model(model)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\base\schema.py", line 286, in create_model
self.execute(sql, params or None)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\base\schema.py", line 111, in execute
cursor.execute(sql, params)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\uti
ls.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\utils\
six.py", line 658, in reraise
raise value.with_traceback(tb)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 62, in execute
return self.cursor.execute(sql)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\sqlite3\base.py", line 316, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: table "Index_usermanagement" already exists
(proj1) C:\Users\vetri\Google Drive\proj1\src>
在进行迁移之前你必须有 运行 syncdb 或者另一个可能的原因是你使用的数据库的其他版本已经有这个 table
尝试删除已经存在的 table 'Index_usermanagement'!
之后又 运行
python manage.py migrate
看起来您可能要为已有 table 的模型迁移到 Django 1.8。对于 Django 1.8,您需要使用 --fakeinitial
选项,该选项过去是隐式的,但现在必须从 1.8 开始显式调用。
文档:
https://docs.djangoproject.com/en/1.8/ref/django-admin/#django-admin-option---fake-initial
这是错误消息:不确定异常消息的含义。另外,运行 本地服务器时我似乎没有收到任何错误。那么以后会不会报错呢?
(proj1) C:\Users\vetri\Google Drive\proj1\src>python manage.py mak
emigrations
No changes detected
(proj1) C:\Users\vetri\Google Drive\proj1\src>python manage.py mig
rate
Operations to perform:
Synchronize unmigrated apps: messages, staticfiles
Apply all migrations: contenttypes, sessions, admin, Index, auth
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying Index.0001_initial...Traceback (most recent call last):
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 62, in execute
return self.cursor.execute(sql)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\sqlite3\base.py", line 316, in execute
return Database.Cursor.execute(self, query)
sqlite3.OperationalError: table "Index_usermanagement" already exists
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\base.py", line 441, in execute
output = self.handle(*args, **options)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\commands\migrate.py", line 221, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\executor.py", line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake, fake_initial=f
ake_initial)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\executor.py", line 147, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\migration.py", line 115, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, projec
t_state)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\operations\models.py", line 59, in database_forwards
schema_editor.create_model(model)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\base\schema.py", line 286, in create_model
self.execute(sql, params or None)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\base\schema.py", line 111, in execute
cursor.execute(sql, params)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\uti
ls.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\utils\
six.py", line 658, in reraise
raise value.with_traceback(tb)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 62, in execute
return self.cursor.execute(sql)
File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\sqlite3\base.py", line 316, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: table "Index_usermanagement" already exists
(proj1) C:\Users\vetri\Google Drive\proj1\src>
在进行迁移之前你必须有 运行 syncdb 或者另一个可能的原因是你使用的数据库的其他版本已经有这个 table 尝试删除已经存在的 table 'Index_usermanagement'! 之后又 运行
python manage.py migrate
看起来您可能要为已有 table 的模型迁移到 Django 1.8。对于 Django 1.8,您需要使用 --fakeinitial
选项,该选项过去是隐式的,但现在必须从 1.8 开始显式调用。
文档:
https://docs.djangoproject.com/en/1.8/ref/django-admin/#django-admin-option---fake-initial