更新 django 数据库以反映现有模型的变化 [英] update django database to reflect changes in existing models

查看:20
本文介绍了更新 django 数据库以反映现有模型的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经定义了一个模型并通过 manager.py syncdb 创建了它的关联数据库.现在我已经向模型添加了一些字段,我再次尝试了 syncdb,但没有出现任何输出.在尝试从我的模板访问这些新字段时,我收到一个No such Column"异常,这让我相信 syncdb 并没有真正更新数据库.这里的正确命令是什么?

I've already defined a model and created its associated database via manager.py syncdb. Now that I've added some fields to the model, I tried syncdb again, but no output appears. Upon trying to access these new fields from my templates, I get a "No Such Column" exception, leading me to believe that syncdb didn't actually update the database. What's the right command here?

推荐答案

看起来你需要的是一个迁移系统.South 真的很棒,工作得很好,有一些自动化工具可以简化您的工作流程.并且有一个很棒的教程.

Seems like what you need is a migration system. South is really nice, working great, has some automation tools to ease your workflow. And has a great tutorial.

注意:syncdb 无法更新您现有的表.有时无法自动决定要做什么 - 这就是为什么南方脚本如此出色.

note: syncdb can't update your existing tables. Sometimes it's impossible to decide what to do automagicly - that's why south scripts are this great.

这篇关于更新 django 数据库以反映现有模型的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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