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

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

问题描述

我已经定义了一个模型,并通过 manager.py syncdb 创建了关联的数据库。现在我已经在模型中添加了一些字段,我再次尝试了 syncdb ,但是没有出现任何输出。尝试从我的模板访问这些新的字段时,我得到一个不这样的列异常,导致我相信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天全站免登陆