Python and Django on Vagrant

Well, this is going to be another straight forward post with loads of shell commands. The background is simple, I love OS X for the many apps it offers but at the same time I always had the joy of developing on a Linux machine. I decided to use Vagrant to have one central box for my projects. I use separate vagrant boxes for complicated projects. But didn’t like the idea of having individual boxes for simple ones.

I work on Python and Django a lot. So in this post I am going to document my setup.

Vagrant File:

# I have assigned a private IP to the box
# I have assigned a hostname to it.
# I am using Ubuntu Precise Pangolin 64 bit as my base box (which I already have added)

Hosts File (/etc/hosts):

After I setup the box, I logged in using SSH:

Now, the usual Ubuntu setup.

Bash Profile in the Ubuntu machine:

# To make the Django built in server available from outside the box I need to run it on so that it listens on all interfaces. So I added a handy alias.

# Added the virtualenv stuff to the profile

Bootstrapping a project:

Now the app would be available on:

I also modify the ~/.virtualenvs//bin/postactivate script to cd into the project source directory. Saves time when I hit “workon env_name”

That’s it 🙂

4 Comments Python and Django on Vagrant

  1. Mushfiq

    Nice post!

    You can also automate the dependency installation via Vagrant provisioning,


  2. Pingback: Виртуальное окружение в Python — This is nothing more than a notebook

Leave a Reply

Your email address will not be published. Required fields are marked *