4
我正在使用django 1.8.2,並且突然間我不能再使用migrate
了。django 1.8.2:創建新內容類型時出錯
我搜查了很多,發現this post暗示我應該從django_content_type
表中刪除name
。但該列不在django_content_type
表中。
這裏是我的django_content_type
表:
id | app_label | model
----+-------------------+----------------
1 | admin | logentry
2 | auth | permission
3 | auth | group
4 | auth | user
5 | contenttypes | contenttype
6 | sessions | session
7 | centuryPhotograph | temporaryuser
8 | centuryPhotograph | userinfo
9 | centuryPhotograph | log
10 | centuryPhotograph | uploadedimages
(10 rows)
這裏是完整的錯誤:
System check identified some issues:
WARNINGS:
centuryPhotograph.Galleries.closed: (1_6.W002) BooleanField does not have a default value.
HINT: Django 1.6 changed the default value of BooleanField from False to None. See https://docs.djangoproject.com/en/1.6/ref/models/fields/#booleanfield for more information.
centuryPhotograph.Galleries.open_gallery: (1_6.W002) BooleanField does not have a default value.
HINT: Django 1.6 changed the default value of BooleanField from False to None. See https://docs.djangoproject.com/en/1.6/ref/models/fields/#booleanfield for more information.
Operations to perform:
Apply all migrations: admin, centuryPhotograph, contenttypes, auth, sessions
Running migrations:
No migrations to apply.
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 165, in handle
emit_post_migrate_signal(created_models, self.verbosity, self.interactive, connection.alias)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/sql.py", line 268, in emit_post_migrate_signal
using=db)
File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 198, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/management/__init__.py", line 83, in create_permissions
ctype = ContentType.objects.db_manager(using).get_for_model(klass)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/models.py", line 58, in get_for_model
" is migrated before trying to migrate apps individually."
RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.
這裏是我的INSTALLED_APPS:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'centuryPhotograph',
)
我刪除了所有遷移一次,並試圖遷移,但問題仍然存在。
嘗試使用'./manage.py migrate contenttypes'遷移contenttypes應用程序。 – Alasdair
謝謝。那做了一些事情(我不知道是什麼!)。錯誤消失了。我可以'makemigrations'和'migrate'沒有任何錯誤。但遷移不適用:( –
我不確定你的意思是「不適用」。什麼是「不適用」的遷移的內容什麼是./manage.py showmigrations的輸出是什麼''當你從'django_migrations'中選擇*時,它與db的內容是否匹配? – Alasdair