What should I use instead of syncdb in Django 1.9?

后端 未结 4 958
长情又很酷
长情又很酷 2020-12-01 01:56

Take a look at this:

$ pypy ./manage.py syncdb
/usr/lib64/pypy-2.4.0/site-packages/django/core/management/commands/syncdb.py:24: RemovedInDjango19Warning: Th         


        
4条回答
  •  隐瞒了意图╮
    2020-12-01 02:30

    You should definitely use migration system. Which lets you track changes in your models.py, and create migrations for the database. The migration system uses the commands makemigrations to create migrations and migrate to migrate the database.

    If for whatever reason you need to create a database the same way syncdb did it there is command flag that causes migrate to work the same way. You should only do this if you REALLY need it and you know what you are doing. For example to create an empty database on for a continuous integration system of your choice.

    python manage.py migrate auth
    # performs migrations for auth and contenttypes contrib apps
    
    python manage.py migrate --run-syncdb
    # creates the rest of the database
    

    Tested on Django 1.9.1.

提交回复
热议问题