5.2. Development Machine

My preference for the development machine is to create a virtual machine using VirtualBox Manager. Apart from the numerous benefits of VMs it also allows me to mirror my production machine as closely as possible. The benefits of this include practising the install process and also encountering any major issues with before it gets the production stage.

Follow the instructions for installing VirtualBox in your own distro then install the development distro and name it consistently e.g. Ubuntu 20.04 - Web Dev.

5.2.1. Create a Development Machine

Configure the new virtual machine according to the instructions for your chosen system. For VirtualBox I use the following:

  • Base memory 4096 MB

  • Video memory 60 MB

  • Storage 42GB, dynamically allocated

  • Processor can stay at 2 core

  • Shared Clipboard and Drag n Drop

Note

The specific allocations will depend on the resources you have available on the host computer.

5.2.2. Initial set up

First create a fresh install with a SUDO user and password of your choice.

If SUDO is not set up as part of installation, you can add permissions by running visudo as root and adding the following line:

newusername ALL=(ALL:ALL) ALL

There are various ways to set up your system so do not feel constrained by this guidance:

  • Set up hostname. What it is doesn’t really matter, but shorter fits the terminal better

  • There’s no point choosing to log in automatically because the encryption key still needs unlocking each time

  • Connect to livepatch

  • Updates (sudo apt-get update && sudo apt-get upgrade)

  • Install any preferred software such as chromium, geany, SpiderOak (if you use it)

  • Add shortcuts to the menu - Terminal

  • Install Virtualbox Guest Additions

5.2.2.1. Django Software Requirements

The Web Dev machine does not need all the production software but it may alert you to software incompatibilities so my preference is to install it.

Check for updates and install the following software:

sudo apt update && sudo apt upgrade
sudo apt install virtualenv git postgresql postgresql-contrib supervisor nginx redis fail2ban libjpeg-dev libpng-dev libgif-dev libpq-dev python-dev

5.2.3. Using an existing Django application

Refer to the Virtualenv instructions for creating and activating a Python environment for your project.

Refer to the Git instructions for downloading the Existing Project.

Refer to the pip instructions for installing required software from requirements.txt.

Refer to the Django instructions for creating the local_settings.py file.

5.2.4. Creating a new Django application

Refer to the Virtualenv instructions for creating and activating a Python environment for your project.

Refer to the pip instructions for installing required software.

Refer to the Django instructions for setting up the Django project.

Refer to the Git instructions for setting up Version Control.

5.2.4.1. Database

For development in Django you can use a simple sqlite database that is just a file in the project folder and is simpler to set up and wipe and start fresh. Sometimes it is worth setting up a database to mirror production.