创建新内容类型时出错。请确保在尝试单独迁移应用程序之前迁移内容类型 [英] Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually
问题描述
我正在尝试从 Django 1.6
迁移到 Django 1.8
。我正在使用 South
来管理Django 1.6中的迁移
。我已经通过 python manage.py makemigrations
成功创建了新的迁移文件。在运行 python manage.py migrate -fake-initial
时,我收到这个错误
I am trying to migrate from Django 1.6
to Django 1.8
. I was using South
for managing migrations
in Django 1.6. I have successfully created new migration files by python manage.py makemigrations
. while running python manage.py migrate --fake-initial
, I am getting this error
Traceback (most recent call last):
File "manage.py", line 39, in <module>
execute_from_command_line(sys.argv)
File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site- packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site- packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 225, in handle
emit_post_migrate_signal(created_models, self.verbosity, self.interactive, connection.alias)
File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site-packages/django/core/management/sql.py", line 280, in emit_post_migrate_signal
using=db)
File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 201, in send
response = receiver(signal=self, sender=sender, **named)
File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 82, in create_permissions
ctype = ContentType.objects.db_manager(using).get_for_model(klass)
File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", line 78, in get_for_model
"Error creating new content types. Please make sure contenttypes "
其中一个迁移文件 0001_initial.py
说:
One of the migration file 0001_initial.py
says:
dependencies = [
('auth', '0006_require_contenttypes_0002'),
('clients', '0002_auto_20150428_1551'),
('players', '0001_initial'),
]
我猜是特别的问题,什么可以解决这个问题,任何帮助将不胜感激。
which I guess is particularly the problem. What could be the workaround this problem. Any help will be appreciated.
推荐答案
根据 ContentType.name 有关。 com / django / django / commit / b4ac23290772e0c11379eb2dfb81c750b7052b66>这个,但不知何故,它不起作用。
I think this has something to do with "The removal of ContentType.name
", according to this. But somehow it doesnt work.
通过手动删除列名称
from'django_content_type'table。例如
By manually removing the column name
from 'django_content_type' table. Eg.
'ALTER TABLE django_content_type DROP COLUMN name'
我能够o应用迁移,也许这可以让你有点进一步。
I was able to apply the migrations. Maybe this can get you a little bit further at least.
这篇关于创建新内容类型时出错。请确保在尝试单独迁移应用程序之前迁移内容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!