Django South:为多个应用程序创建schemamigration [英] Django South: Creating schemamigration for more than one app

查看:187
本文介绍了Django South:为多个应用程序创建schemamigration的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个更大的项目上使用django south,我唯一不喜欢的,你不能一次为所有的应用程序创建schemamigrations(我有很多应用程序继承相同的抽象模型,如果我改变那个基本模型有很多应用程序要迁移) - 想想你可以实际迁移所有的一次(使用migrate --all)。

I'M using django south on a bigger project, the only thing I don't like about it, that you can't create schemamigrations for all of your apps at once (I have a lot of apps that inherit from the same abstract model, if I change that base model there are alot of apps to migrate) - thought you can actually migrate all of them at once (using migrate --all).

所以我想知道,如果这是一个简单的解决方案django南一次处理一堆应用程序,或者任何人有一个漂亮的脚本准备好了吗?

So I'd like to know if theres an easy solution for django south to handle a bunch of apps at once or if anyone has a nice script ready for doing that?

推荐答案

第一件事:单独的应用程序应该限制模型交互

First thing: separate applications should limit model interactions

就是说,让我们接受约束。没有南部不能为许多应用程序创建单个迁移文件,我不知道如何在一个manage.py命令中为许多应用程序生成许多迁移。

now that it's said, let's embrace the constraint. No south cannot create a single migration file for many apps and I don't know how to generate many migrations for many app in a single manage.py command.

现在是一个脚本。您可以使用令人惊叹的结构 http://docs.fabfile.org/ 获得一个命令来生成迁移:

All that is left to you is a script now. You could use the amazing fabric http://docs.fabfile.org/ to have a single command to generate your migrations :

APPS_TO_WATCH = ['myapp','myotherapp','toomanyapps']
def migration():
    for app in APPS_TO_WATCH:
        local('python manage.py schemamigration %s --auto' % app)

,然后使用
fab migration

and then call it using fab migration

这篇关于Django South:为多个应用程序创建schemamigration的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆