简体   繁体   English

将Django模型部署到Web服务器后,如何对其进行更改?

[英]How do I make changes to a Django Model after it has been deployed to a webserver?

In development, whenever I make changes to the underlying model in my Django application, I'm used to: 在开发中,每当我在Django应用程序中对底层模型进行更改时,我习惯于:

  1. Stopping the development server 停止开发服务器
  2. In MySql, dropping the existing database 在MySql中,删除现有数据库
  3. running $>python manage.py syncdb 运行$> python manage.py syncdb
  4. Restarting the development server by running $>python manage.py runserver 通过运行$> python manage.py runserver重新启动开发服务器

Once deployed using WSGI & Apache, however, I don't have the development server running. 但是,一旦使用WSGI和Apache部署,我就没有运行开发服务器。 As such, I don't know how to stop the server, and just running: 因此,我不知道如何停止服务器,只是运行:

$>python manage.py syncdb $> python manage.py syncdb

didn't appear to update the underlying MySql database that instantiates the model. 似乎没有更新实例化模型的底层MySql数据库。 So, short of tearing down the entire instance, how do I update my database? 因此,如果没有拆除整个实例,我该如何更新我的数据库?

Note: I implemented this before I learned about db migrations using "south" so I'm looking at raw Django, I suspect. 注意:我使用“south”了解db迁移之前实现了这一点所以我怀疑是看着原始的Django。

Django doesn't have a migration framework built-in (yet!), so there's no such thing as "raw django for migrations". Django没有内置的迁移框架(还有!),所以没有“raw django for migrations”这样的东西。

Consequently, you either do that manually (using SQL to alter the table), or you use south. 因此,您可以手动执行此操作(使用SQL更改表),也可以使用south。

Now, my recommendation would be to use south . 现在,我的建议是使用south

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM