简体   繁体   中英

Django Production Deployment : Should we not remove source files ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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