【发布时间】:2016-01-10 05:54:32
【问题描述】:
yekabathula-macbookair2:roster yekabathula$ python manage.py migrate
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: admin, contenttypes, api, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying api.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying sessions.0001_initial... OK
yekabathula-macbookair2:roster yekabathula$ python manage.py syncdb
/Library/Python/2.7/site-packages/django/core/management/commands/syncdb.py:24: RemovedInDjango19Warning: The syncdb command will be removed in Django 1.9
warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning)
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: admin, contenttypes, api, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
No migrations to apply.
在执行 python manage.py migrate 之后,没有从我的 models.py 在数据库中创建表,它能够从 django_session 等创建其他表。还有什么我需要在这里遵循的吗?
【问题讨论】:
-
在做
migrate之前你做makemigrations吗? -
是的,我做到了。使用
makemigrations,它可以创建迁移文件。但是当我做migrate时,它并没有创建表格。 -
如果您正在升级,请确保从迁移目录中删除所有旧的南迁移文件。
-
@YSK,如果这仍然是一个问题,您可以发布您的 models.py 文件的代码吗?可能是Model Meta类中
Options.managed设置为False。