为什么django manage.py syncdb无法在我的开发服务器上创建新的列? [英] Why is django manage.py syncdb failing to create new columns on my development server?

查看:131
本文介绍了为什么django manage.py syncdb无法在我的开发服务器上创建新的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从生产服务器创建一个开发服务器,从中我可以测试出新的想法。

I am trying to create a development server from a production server from which I can test out new ideas.

我通过转储创建了我的生产服务器的数据库副本它使用Postgres' db_dump ,然后将转储导入到新的数据库。

I created a duplicate of my production server's database by dumping it using Postgres' db_dump and then imported the dump into a new database.

然后我复制了我的生产django目录并修改所有 .py 文件以引用 server_debug。而不是服务器 import 语句

I then copied my production django directory and altered all .py files to refer to server_debug. rather than server in my import statements.

使用管理界面修改一些数据,只有开发服务器的数据已更改。

Using the admin interface to alter some data works in that only the development server has its data altered.

但是,当我尝试在我的 models.py 中添加一个新的字段我的开发服务器 manage.py syncdb 无法创建它。

However, when I then try adding a new field in my models.py in my development server, manage.py syncdb fails to create it.

有什么我忽略的可能会导致 manage.py 指代我的生产服务器,而不是我的开发服务器?

Is there something I am neglecting that could cause manage.py to refer to my production server rather than my development server?

推荐答案

syncdb 不会触摸已经存在的表。您需要重新设置应用程序(如果您不关心数据,最简单),手动修改表格(更多的是hack)或使用迁移应用程序和版本的模型 - South ,例如。

syncdb doesn't touch tables that already exist. You need to either reset the app (easiest if you don't care about the data), modify the table manually (more of a quick hack) or use a migration app and version your models — South, for example.

这篇关于为什么django manage.py syncdb无法在我的开发服务器上创建新的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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