Home:ALL Converter>How to deploy a Django to the production server without mercurial files?

How to deploy a Django to the production server without mercurial files?

Ask Time:2012-08-06T18:16:09         Author:Houman

Json Formatter

I am originally a .NET developer and back then when we had to release a software from Visual Studio, we had to switch it to release mode to make sure the debug hooks are removed and the repository files are left behind. The end result was a clean set of files ready to be pushed into production.

After switching to Django and working with it for nearly three months I am now ready to deploy the first app. I have done quite some reading on it. I know how to set the debug to False and having a production_setting.py and how to deploy with WSGI on Apache.

But something I still haven't figured out is a nice process to push out a release.

With what I know now, I would do the following for a release:

  • Copy all the files by hand to a upload directory (excluding hidden mercurial directories)
  • Zip them all
  • sending them over SCP to the Ubuntu server
  • Logging into the server
  • Extracting the zip file and putting everything into place
  • Modifying the setting_production.py and enter the credentials

Is this a healthy process for Django deployment? :)
FYI I am using Aptana Studio 3.2.1

Thanks for any tips

Author:Houman,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/11826334/how-to-deploy-a-django-to-the-production-server-without-mercurial-files
supervacuo :

You could look into Fabric; the documentation describes it as\n\n\n ... a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.\n\n\nIt is capable of doing all the things you want it to.\n\nYour \"deploy\" task would probably have several sub-tasks (_upload_tar_from_hg(), _migrate() etc.), but the overall picture would be something like:\n\nfrom fabric.api import * \n\nenv.release_name = 'foo_bar-1.0'\nenv.deployment_path = '/var/www/django/%s' % env.release_name \n\ndef deploy():\n local('hg archive -t tgz $s.tar.gz' % env.release)\n put('%s.tar.gz' % env.release, env.deployment_dir)\n run('cd %s && tar -xzvf %s.tar.gz' % (env.deployment_path, env.release))\n local('rm %s.tar.gz' % env.release)\n run('cd %s/%s && ln -s settings_production.py settings.py' % (env.deployment_path, env.release))\n\n\nThis relies on having a separate settings_production.py in source control, which may not be appropriate. Fabric can find-and-replace in text files, or you could combine settings using a local_settings.py approach.\n\nCheck out the Fabric tutorial to fill in the gaps (like specifying connection details for your server. Once you're set up, just run\n\nfab deploy\n\n\nand the process should proceed automatically.\n\nNB creating an archive from Mercurial without hg metadata is accomplished in one step with the hg archive command)",
2012-08-06T14:33:16
yy