在版本控制中存储 Django 和应用程序代码的好处

发布于 2024-10-19 05:11:21 字数 217 浏览 7 评论 0原文

我试图简化我们的应用程序的部署,并更轻松地管理我们依赖的库和框架的版本。

将 Django 存储在我们的 VCS 中有意义吗?理想情况下,这将使我更轻松地简化部署,并且我可以使用 South 管理 Django 对内置应用程序(django.contrib.auth、django.contrib.sites 等)所做的任何模型更改。

我有什么理由不应该这样做吗?您为您的应用程序做什么?

I'm trying to simply the deployment of our application and more easily manage the versions of libraries and frameworks that we depend on.

Does storing Django in our VCS make sense? This would ideally make it easier for me to streamline deployment and I can manage any model changes that Django makes to the built-in apps (django.contrib.auth, django.contrib.sites, etc.) using South.

Are there reasons why I shouldn't do this? What do you do for your apps?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

z祗昰~ 2024-10-26 05:11:21

我绝对会把所有东西都存储在你的 VCS 中。想要更新 Django?想要添加插件吗?在几个开发人员和不同环境之间同步可能是一场噩梦。如果版本不同步,不必调试它。如果您需要使用多个 django 应用程序并且它们是不同的版本,会发生什么情况?

您可能需要查看以下两篇文章:

我存储 virtualenv 在 SVN 中创建的目录中的所有内容。我的部署脚本基本上由以下内容组成:

  • 将项目签出(仅最初,然后更新)到服务器上的文件夹
  • rsync 到 Apache 提供文件的目录(不包括 .svn 文件夹)
  • 设置该环境的数据库密码和权限
  • 重新启动乘客
  • 写出从工作副本到部署目录的文本文件的修订号(稍后可能会派上用场!)

I would absolutely store everything in your VCS. Want to update Django? Want to add a plugin? Synchronising this across a few developers and different environments could be a nightmare. Nevermind having to debug this if the versions go out of sync. What happens if you have multiple django apps that you need to work on and they're different versions?

You might want to take a look at the following two articles:

I store everything from the directory that virtualenv creates in SVN. My deployment script basically consists of the following:

  • Checkout (only initially, and then update) project to folder on server
  • rsync to directory that Apache serves files out of (excluding .svn folders)
  • Set database passwords and permissions for that environment
  • Restart passenger
  • Write out revision number to text file from working copy to deployment directory (could come in handy later!)
浪漫之都 2024-10-26 05:11:21

我认为将 Django 本身存储在版本控制中不会获得太多好处,除非您使用的是 Django 的修改版本。听起来您正在与其他开发人员合作,因此一定要将您正在处理的代码存储在某些 VCS 中(即使单独工作也有很多好处)。

为了部署您的应用程序,您可能会发现构建一个可以指定其依赖项(例如特定版本的 Django)的 distutils 包是值得的。使用 virtualenv 将有助于跟踪依赖关系。

我建议,要发布到生产服务器,您应该“标记”每个版本,然后将其导出到您的生产系统,而不是检查它。这有助于阻止人们更新标签内的内容以及从版本控制进行更新。

我认为在发布到生产系统时值得做的另一件事是为每次导出的代码创建一个新目录,其中包括发布号,然后有一个指向活动版本的符号链接。这使您可以轻松回滚到以前的版本。你提到的南方对此也很有帮助。

I don't think you'll gain much by storing Django itself in version control unless you are using a modified version of Django. It sounds like you're working with other developers, so definitely store code you're working on in some VCS (even working alone there are plenty of benefits).

For deploying your application you may find it's worth building a distutils package which can specify its dependencies (such as a specific version of Django). Using virtualenv will help keep track of dependencies.

I would suggest that for releasing to a production server you should "tag" each release and then export that to your production system, rather than checking it out. This helps to stop people updating things within the tag and updating from version control.

Another thing that I think is worthwhile doing when releasing to a production system is creating a new directory for each export of the code which includes the release number, then have a symlink pointing to the active version. This allows you to roll back to a previous version easily. South, which you mention is also very helpful for this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文