Open ChenChiungAn opened 8 years ago
@ChenChiungAn
Hi, 當你新創一個專案時可以看看settings.py
內容, 如: https://github.com/its-django/mysite/blob/module_04/mysite/mysite/settings.py#L32
裡面就有contenttype.
抱歉, 這裡說明的不夠明確,
在執行python manage.py migrate restaurants 0001
前須先執行python manage.py migrate
將內建的app先行migrate, 讓Django自身機制能夠完全
@myyang, 謝謝您,成功了
各位大大們好,當我執行P133模型與資料庫同步時 python manage.py migrate restaurants 0001 出現以下錯誤 我的環境是python 2.7.10 Django 1.7.1 Operations to perform: Target specific migration: 0001_initial, from restaurants Running migrations: No migrations to apply. Traceback (most recent call last): File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/giantkilling/It_is_Django/local/lib/python2.7/site-packages/django/core/management/init.py", line 385, in execute_from_command_line
utility.execute()
File "/home/giantkilling/It_is_Django/local/lib/python2.7/site-packages/django/core/management/init.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/giantkilling/It_is_Django/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(_args, _options.dict)
File "/home/giantkilling/It_is_Django/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(_args, _options)
File "/home/giantkilling/It_is_Django/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 164, in handle
emit_post_migrate_signal(created_models, self.verbosity, self.interactive, connection.alias)
File "/home/giantkilling/It_is_Django/local/lib/python2.7/site-packages/django/core/management/sql.py", line 268, in emit_post_migrate_signal
using=db)
File "/home/giantkilling/It_is_Django/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 198, in send
response = receiver(signal=self, sender=sender, named)
File "/home/giantkilling/It_is_Django/local/lib/python2.7/site-packages/django/contrib/auth/management/init**.py", line 83, in create_permissions
ctype = ContentType.objects.db_manager(using).get_for_model(klass)
File "/home/giantkilling/It_is_Django/local/lib/python2.7/site-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.
就網路所搜尋的結果來看 https://code.djangoproject.com/ticket/24099 是需要移除ContentType.name,但就現階段我連contenttype.name在哪個位置都不太清楚,懇請各位大大的協助。