gpt4 book ai didi

django - 南与 django 1.7

转载 作者:行者123 更新时间:2023-12-04 03:51:20 25 4
gpt4 key购买 nike

我正在为我的应用程序使用 django 1.7。我遇到了几个迁移问题。每次我尝试更改作为外键的模型中的字段名称时,它都会中断。唯一的解决办法是去数据库修复它,然后他们运行 migrate其次是 syncdb .
随着我的应用程序变得越来越大,我将如何解决这些问题,并且随着架构的变化,我很快就会花更多的时间来解决数据库错误。
django 1.7 不支持 South 并且有自己的迁移功能,但功能不强?(我不确定,只是初学者)

最佳答案

Django 1.7 中的迁移框架基于 South。如果您正在升级,您应该阅读以下内容:

https://docs.djangoproject.com/en/1.7/topics/migrations/#upgrading-from-south

从文档:

Upgrading from South If you already have pre-existing migrations created with South, then the upgrade process to use django.db.migrations is quite simple:

Ensure all installs are fully up-to-date with their migrations. Remove 'south' from INSTALLED_APPS. Delete all your (numbered) migration files, but not the directory or init.py - make sure you remove the .pyc files too. Run python manage.py makemigrations. Django should see the empty migration directories and make new initial migrations in the new format. Run python manage.py migrate. Django will see that the tables for the initial migrations already exist and mark them as applied without running them. That’s it! The only complication is if you have a circular dependency loop of foreign keys; in this case, makemigrations might make more than one initial migration, and you’ll need to mark them all as applied using:

python manage.py migrate --fake yourappnamehere

关于django - 南与 django 1.7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26263871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com