One tool I’ve come to appreciate recently is Vagrant. Vagrant allows you to run a portable, virtual, OS instance. This means that if you work on more than one machine you don’t have to worry about having the same environment set up on each one. The vagrant install mounts your local home directory in the vagrant instance too (if you install VBoxGuestAdditions -hint: scp the iso to the Vagrant instance and install it from there, not on the real computer), so you able to use a local IDE install (e.g. Pycharm) as your editor while running the code on your vagrant instance.
Getting the development server to run for Django is straightforward. First, install Vagrant using their install advice. Then edit the VagrantFile you are using by uncommenting or adding the following lines:
config.vm.network :private_network, ip: “192.168.33.10” # good default
config.vm.network :forwarded_port, guest: 80, host: 8080 # good default
config.vm.synced_folder “./host_dir/”, “/vagrant/mount/location” # if you’re automounting (you’ll need VBoxGuestAddtion installed)
- Log in to your vagrant instance (default user/password=vagrant/vagrant) .
- Install and create a virtualenv (optional – but usually a good idea).
- Install django and a database.
- Create a django app (it can be empty).
- Start the django dev server with python manage.py runserver 192.168.33.10:8080 (given you used the above settings)
- Point your browser at http://192.168.33.10:8080/ .
If everything went well you should see a Django “It Worked!” screen.