Django 构建

发布于 2024-09-08 10:32:52 字数 119 浏览 4 评论 0原文

我开始尝试使用 Django 的构建。我想使用构建作为部署项目和应用程序的主要安装方法。在这种情况下,每个应用程序都包含一个构建项目以及项目是最好的吗?您应该在什么级别应用构建?

谢谢,

托德

I'm starting to play around with using buildout for Django. I'd like to use buildout as the main installation method for deploying projects and applications. In this context is it the best that each application contains a buildout, as well as the project? At what level should you apply the buildout?

Thanks,

Todd

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

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

发布评论

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

评论(4

停滞 2024-09-15 10:32:52

我通常设置它的方式是这样的:

buildout_dir/
  + bootstrap.py
  + buildout.cfg
  + ...
  + <project_name>/
      + settings.py
      + templates/
      + media/
      + ...  

由于无论如何构建(在我的例子中)通常与单个项目绑定,所以我将直接将 django 项目存储在构建中。顺便说一句:我在构建配置中使用 djangorecipe

我编写的应用程序很简单,并且具有这种布局:

django-<app_name>/
  + setup.py
  + <app_name>/
      + __init__.py
      + models.py
      + ...

但我也见过一些独立构建的应用程序。 Jacob Kaplan-Moss 甚至写了一篇关于它的文章

The way I usually set it up is like this:

buildout_dir/
  + bootstrap.py
  + buildout.cfg
  + ...
  + <project_name>/
      + settings.py
      + templates/
      + media/
      + ...  

Since the buildout is (in my case) often tied to a single project anyway, I'll just store the django project directly inside the buildout. By the way: I'm using djangorecipe in my buildout configuration.

The applications I write are simple eggs and have this kind of layout:

django-<app_name>/
  + setup.py
  + <app_name>/
      + __init__.py
      + models.py
      + ...

But I've also seen apps that are a self contained buildout. Jacob Kaplan-Moss even wrote an article about it.

雨夜星沙 2024-09-15 10:32:52

我总是在项目(网站)根目录下至少有两个/三个构建配置:

/
|- buildout.cfg    # contains bas configuration used by other cfg files
|- development.cfg # adds ton of eggs used only in development and generates manage script using djangorecipe 
|- production.cfg  # most of the time it contains versions and generates django script using djangorecipe

I always have at least two/three buildout configs at project (website) root:

/
|- buildout.cfg    # contains bas configuration used by other cfg files
|- development.cfg # adds ton of eggs used only in development and generates manage script using djangorecipe 
|- production.cfg  # most of the time it contains versions and generates django script using djangorecipe
谁人与我共长歌 2024-09-15 10:32:52

对我来说,我为每个应用程序和每个项目都提供了扩展。该项目的扩建是为了建立网站。包括:

  • 生成一个apache/nginx配置文件(collective.recipe.template)

  • 也许是一个cronjob

  • 也许是主管,如果你想运行一个单独的gunicorn等。

每个应用程序都有一个扩展。这里的目标是轻松设置隔离环境,特别是用于测试。您永远不需要部署应用程序,您只需要对其进行足够的设置即可运行开发服务器并运行测试。

对我来说,构建就是隔离(如 virtualenv)加上安装(如 pip)加上项目自动化。您主要将前两个用于应用程序。这三个都是该网站的。

For me, I give every app and every project a buildout. The project's buildout is for, well, setting up the site. Including:

  • generating an apache/nginx config file (collective.recipe.template)

  • perhaps a cronjob

  • perhaps supervisor if you want to run a separate gunicorn or so.

Every app also has a buildout. Here the goal is to make it easy to set up an isolated environment especially for testing. You never need to deploy an app, you just need to get it set up enough to run the development server and to run the tests.

For me, buildout is isolation (like virtualenv) plus installation (like pip) plus project automation. You'll mostly use the first two for the apps. And all three for the site.

维持三分热 2024-09-15 10:32:52

我总是为每个项目创建一个构建来获取所有必需的依赖项。这可以是简单的鸡蛋,也可以是使用 mr.developer 的 git(hub) 的内部依赖项,

我认为不需要为每个应用程序构建。为每个 django 设置配置(例如开发、生产等)都有一个匹配的 buildout.cfg 可能会很好。

构建只是在项目文件夹中应用,依赖项将自动包含在内(并且在使用 mr.developer 时可自定义)。

另外,在我看来,包括 bootstrap.py 有点过时;我总是运行 virtualenv + pip install zc.buildout。这也可以在项目文件夹本身或外部完成(例如〜/ virtualenvs / myproject-123)

I always create a buildout per project that fetches all required dependencies. This can be simple eggs but also internal dependencies from git(hub) using mr.developer

I don't see a need to have a per-app buildout. It's probably good to have a matching buildout.cfg for each django settings configuration (e.g. development, production, etc)

The buildout is simply applied at the project folder, dependencies will automatically be included (and customizable when using mr.developer).

also, including bootstrap.py is a bit oldfashioned in my opinion; I always run virtualenv + pip install zc.buildout. This can also be done on the project folder itself, or externally (e.g. ~/virtualenvs/myproject-123)

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