Django Development with Vagrant and Ansible

My basic workflow is to use Vagrant and Ansible to configure a local virtual machine, then use Ansible to configure the production server. The goal is to have the local and production servers be nearly identical.

The both machines serve Django using nginx and gunicorn. I use a Vagrant synced folder to allow me to edit the code during development. I have an terminal with an SSH connection to the Vagrant machine that I use to restart the server when the code changes. This works, but the edit/run cycle is slow compared to the good old days of using the Django development server. How can I get back to using the development server?

One option would be to go back to the old days and install a local virtualenv and database. This seems clumsy to me. The better option is to open an IP address on my local virtual machine and then run Django development machine on that port on the VM. Here are the steps.

1) SSH into the local server and start the virtualenv.

2) Stop nginx:

service nginx stop

3) Run the Django development server on the Vagrant IP address:

python manage.py runserver 192.168.33.16:8000 --settings=myapp.settings.local
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s