Django生产部署:我们是否应该删除源文件? [英] Django Production Deployment : Should we not remove source files ?

查看:90
本文介绍了Django生产部署:我们是否应该删除源文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Django AND Python的新手.当前正在使用Django 1.9进行虚拟项目.因此,按照出色的Django文档,我可以使用apache/mod_wsgi完成部署,并且该部署正在本地计算机上的测试Web服务器上运行.

但是我想知道Python源文件:

我已经给出了我的开发目录的路径-对mod_wsgi和apache配置(httpd.conf)文件说/Python-labs/mysite/.这个开发目录显然包含所有.py文件-Python源文件.

我没有在文档中找到删除源文件等的任何地方.所以我用谷歌搜索,但没有任何作为从生产部署中删除源文件的标准步骤. 得到了-最接近我要的东西:

Django删除源文件

没有Django部署源代码

但同样,它不能使以下问题变得十分清晰:

我的问题:

  1. 在Django部署中,是否删除源文件是否是标准步骤?
    (或者我是否错过了文档中非常明显的内容?)
  2. 如果我们将.py文件放在生产服务器上可以吗?还是打算这样?

非常感谢Advance!

解决方案

通常使用Django部署源文件.只要正确设置了项目(所有项目/应用程序目录都包含__init__.py),Django就会将.py文件编译为.pyc.

要回答您的问题- 1.不要直接提供生产文件;使用优质的VCS将文件推送到生产服务器,或者,如果快速又肮脏,则将项目复制到生产服务器.但是未编译的.py文件是大多数Django项目的标准配置. 2.是的.

要了解更多信息,此问题可能会有所帮助. >

Hi I am a newbie to Django AND Python. Working currently on a dummy project using Django 1.9. So following the excellent Django Documentation I could complete the deployment using apache/mod_wsgi and it is running on a test web server on my local machine.

But I am wondering about the Python source files :

I have given the path to my development directory - say /Python-labs/mysite/ to mod_wsgi and apache configuration ( httpd.conf ) files. This development directory obviously contains all the .py files - the Python source files.

No-where in the documentation i found any mention to remove the source files etc. So I googled but could not get anything as a standard step to remove source files from the production deployment. Got this - the closest to what I am asking for :

Django Remove Source Files

Django Deployment Without Source Code

but again it does not make it crystal clear about the questions below :

My Questions :

  1. Is it a standard step in Django deployment to remove source files or not ?
    ( or Did I miss something very obvious from the documentation ? )
  2. Is it Ok if we put .py files on production server ? Or is it intended that way ?

Thanks a lot in Advance !

解决方案

It is typical to deploy source files with Django. As long as the project is set properly (__init__.py included for all project/app directories) then Django will compile .py files to .pyc.

To answer your questions - 1. Don't serve your production files directly; use a good VCS to push files to your production server or, if quick and dirty, copy your project to your production server. But uncompiled .py files are standard for most Django projects. 2. Yes.

For more insight, this question may help.

这篇关于Django生产部署:我们是否应该删除源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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