Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Marek Kuziel - Deploying Django with Buildout


Published on

Slides from my presenation for NZPUG (

Published in: Technology
  • Be the first to comment

Marek Kuziel - Deploying Django with Buildout

  1. 1. Deploying Django with Buildout Marek Kuziel , Encode Ltd [email_address]
  2. 2. Why Django with Buildout? <ul><li>Setting things up can be a real pain in the arse </li></ul><ul><li>Automation of a repeatable task </li></ul><ul><li>Having everything under control </li></ul><ul><li>Deployment strategy is be something a good developer should care about </li></ul><ul><li>You may find bugs/issues during the build process that you can patch and submit back to the community </li></ul><ul><li>5 minutes to learn. Lifetime to master. </li></ul>
  3. 3. Advantages <ul><li>It's a repeatable task. Things get tested often . </li></ul><ul><li>Great way to deal with development , QA , staging , production </li></ul><ul><li>Standalone Python environment , good for security and developer's sanity ;-) </li></ul><ul><li>Great way to keep your project up-to-date </li></ul>
  4. 4. How do we do things? <ul><li>Non-system-wide Python. Compile Python by hand. Don't mess with system-wide site-packages </li></ul><ul><li>Development , QA , Production Buildout configs </li></ul><ul><li>Development , QA , Staging , Production , Mobile Django settings that load general </li></ul><ul><li>Build Django apps as Eggs. Makes deployment to production easier. </li></ul>
  5. 5. Pre-requisities <ul><li>Python </li></ul><ul><li>*checkout*/zc.buildout/trunk/bootstrap/ </li></ul><ul><li>A terminal, because we'll do everything on a command line. </li></ul>
  6. 6. Let's start <ul><li>mkdir -p ~/projects/djangodemo </li></ul><ul><li>cd ~/projects/djangodemo/ </li></ul><ul><li>note: all commands from now on are executed from ~/projects/djangodemo/ directory </li></ul><ul><li>wget*checkout*/zc.buildout/trunk/bootstrap/ </li></ul><ul><li>or download </li></ul>
  7. 7. Basic Buildout config for Django <ul><li>Create a new file called buildout.cfg </li></ul>[buildout] parts = django [django] recipe = djangorecipe version = 1.0
  8. 8. Let's bootstrap ~/Python/2.5/bin/python <ul><li>running Python 2.5 compiled by hand. Located at ~/Python/2.5/ </li></ul><ul><li>running Buildout's boostrap process with </li></ul>Creating directory '/Users/marek/projects/djangodemo/bin'. Creating directory '/Users/marek/projects/djangodemo/parts'. Creating directory '/Users/marek/projects/djangodemo/eggs'. Creating directory '/Users/marek/projects/djangodemo/develop-eggs'. Generated script '/Users/marek/projects/djangodemo/bin/buildout'.
  9. 9. Let's build ./bin/buildout Installing django. django: Downloading Django from: Generated script '/Users/marek/projects/djangodemo/bin/django'. ... and we're done!
  10. 10. Separating development from production <ul><li>Create a new file called development.cfg </li></ul>[buildout] extends = buildout.cfg parts += django-command-extensions eggs += Werkzeug [django] settings = development pythonpath += ${django-command-extensions:location} [django-command-extensions] recipe = infrae.subversion urls = .
  11. 11. Let's build again ./bin/buildout -c development.cfg Unused options for buildout: 'eggs'. Installing django-command-extensions. Installing django. Generated script '/Users/marek/projects/djangodemo/bin/django'. django: Skipping creating of project: project since it exists ... and we're almost done :)
  12. 12. Adjusting settings <ul><li>Copy INSTALLED_APPS from project/ to project/ </li></ul><ul><li>Add 'extensions' at the end of INSTALLED_APPS tuple </li></ul><ul><li>By copying INSTALLED_APPS to development you keep the production INSTALLED_APPS in and make custom INSTALLED_APPS in </li></ul>
  13. 13. Time to start hacking, eh? <ul><li>./bin/django syncdb </li></ul><ul><li>./bin/django startapp demo </li></ul><ul><li>./bin/django runserver_plus </li></ul>Recommended reading:
  14. 14. Thank you!