What is the difference between syncdb and migrate?

2020-06-03 00:43发布

I am going through django documentation. And here I have a situation. In one of the documentation, I am told to do

python manage.py migrate

And in the other

python manage.py syncdb

I can't do the first one(Error: no migrate command found.) but second works fine for me. Is this a version issue or I need to take care of something else.

3条回答
做自己的国王
2楼-- · 2020-06-03 01:25

It depends what version of the documentation you are reading. migrate is the command from South which up until the latest (currently development, or dev) version of django was a separate app. It's finally getting integrated into Django (basically every django project uses it anyway as a matter of course, so it is well worth reading up on).

In the bottom right of the django documentation page there is a selector where you can switch between different versions of Django, so if you're looking for information for your project it is a good idea to change to the version of Django you're currently using.

查看更多
▲ chillily
3楼-- · 2020-06-03 01:41

The command migrate belongs to an application called south (http://south.aeracode.org/).

From the website:

This is South, intelligent schema and data migrations for ​Django projects.

Prior to Django==1.7 you had to install a third party application in order to perform database migrations.

Please see documentation at readthedocs

查看更多
smile是对你的礼貌
4楼-- · 2020-06-03 01:49

The migrate command is new in the upcoming Django 1.7, which hasn't been released yet.

For earlier versions you can use syncdb, or the external app South.

When you're reading the documentation, use the Documentation version switcher to select the correct version.

For example, the current 1.6 Tutorial uses syncdb, but the dev tutorial (written for the upcoming 1.7) uses migrate.

查看更多
登录 后发表回答