django setup

Provides a shell script to setup django running on a Raspberry Pi.

There are many great tutorials on Django. I create web servers to run on a headless Raspberry Pi. A headless system has no desktop, no keyboard and no monitor.

Most tutorials stop when Django is running on localhost (127.0.0.1, which is either a laptop or the Raspberry Pi's desktop). For me this is not useful, I need Django running on a Raspberry Pi and I can open the website from my laptop.

Since my focus is on python, most tutorials assume django should run within a virtual environment. There are definite advantages to using a virtual environment, however it is not always required.

Required Parts:

  • Raspberry Pi running Raspberry Pi OS

Step 2. From a laptop, open a terminal window and login to the Raspberry Pi

Step 3. Download Files

Run the following commands

$ wget https://raw.githubusercontent.com/dumbo25/django-setup/main/django.sh

$ wget https://raw.githubusercontent.com/dumbo25/django-setup/main/django.cfg

Step 4. Setup Django

Run the command

bash django.sh -h

The -h option shows help. It will show options to use with the script and variables to edit in the .cfg file.

Edit the .cfg to meet your needs, or run it as is. Once the .cfg is ready, run:

bash django.sh

Step 5. See your website

django.sh generates server.sh

To see your website, run the command:

bash server.sh

server.sh will output the URL to open in a browser on your laptop to see your website