Raspberry Pi Django Tutorial
1. Setup Project Files Raspberry Pi Django Web App
This is a Raspberry Pi Tutorial Django project that can be found at: https://github.com/mavieth/Raspberry-Pi-Django-Web-App
mkdir -p ~/projects/django-rpi cd ~/projects/django-rpi/
2. Install Virtual Environment for Django Web App
This is so we can install python packages without having to run with the sudo command for our project.
pip install virtualenv or sudo pip install virtualenv
3. Create Virtual Environment and Activate
After this command you should have an (env) before your terminal to let you know that you have activated the virtual environment.
virtualenv venv && source venv/bin/activate
4. Install Django on your Raspberry Pi, and Create the Project Files
This may take a few minutes as it will be install Django to run on your Raspberry Pi
pip install django django-admin startproject raspberrypiapp cd raspberrypiapp
6. Edit the ALLOWED_HOSTS
On line in ~/projects/django-rpi/raspberrypiapp/raspberrypiapp/settings.py , where 10.0.0.22 is the IP address of your Raspberry Pi
ALLOWED_HOSTS = ["localhost","10.0.0.22"]
7. Migrate Changes and Start the Server!
python manage.py migrate python manage.py runserver 0.0.0.0:8080
This will start an application on http://localhost:8080 or from another computer on the same network http://10.0.0.22:8080 where 10.0.0.22 is the IP address of your Raspberry Pi.
You can find my project files at https://github.com/mavieth/Raspberry-Pi-Django-Web-App
Please comment below if you have any questions!