Part 1: Installing Raspbian, Setting Up the System and Django Project, and First Git Commit
Summary

Part 1: Installing Raspbian, Setting Up the System and Django Project, and First Git Commit
Install Raspbian on a SDCard on macOS:
sudo dd bs=1m if=/path/to/raspbian/image.img of=/dev/rdisknumber conv=sync
We will use SSH to connect to the headless Raspberry (not connected to a monitor). Once done, go to the SDCard, in the boot folder create a file named ssh (without an extension). Unmount the card, plug in your Raspberry. To find the IP address of your Pi, you can use Fing on your smartphone or use the command below that will list the IP addresses of every devices connected to your network (you will have to test each one out though). First install Homebrew if not already on your system, nmap a network analysis tool:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then nmap:
brew install nmap
You will need to find out your router IP address scheme, to do so run this command:
netstat -rn |grep default
According to the scheme used run:
nmap -A xxx.xxx.x.0/24
Now, SSH to it using:
ssh pi@xxx.xxx.x.(x)x
The default password for pi user will be raspberry, therefore you have to change it immediately:
passwd
Update Raspbian:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
Remove the Perl error caused by missing locales:
export LANGUAGE=en_GB.UTF-8
export LANG=en_GB.UTF-8
export LC_ALL=en_GB.UTF-8
sudo locale-gen en_GB.UTF-8
sudo dpkg-reconfigure locales
Select en_GB.UTF-8
Add a user specifically for the Django project:
sudo adduser name_of_system_user
Make the user a sudoer so he can access system services, install packages,… :
sudo gpasswd -a name_of_system_user sudo
Switch to the Django project system user:
sudo su - name_of_system_user
Install pip 3 (Python program to install Python3 packages) and Virtualenv to create multiple projects with Django that won’t interfere with one another on the local machine (each package installed under this virtual environment only): Download and install pip3:
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
Install the Virtualenv package:
pip3 install virtualenv
Memo: to install a package from a URL, Github for example:
pip3 install -e git://github.com/name_of_user/name_of_repo#egg=name_of_repo
During the pip freeze command (to write down all requirements for the project), it will write down the correct URL where to install the repo from.
Create a folder for the whole Django project
mkdir django_project
Change to the new directory
cd django_project
Create a virtual environment that will use Python3:
virtualenv venv -p python3
Activate the virtual environment:
source venv/bin/activate
To get out of the virtual env, especially important not to forget as you swap between different.
deactivate
Install NGINX that will process all requests addressed to the server:
sudo apt-get install nginx
Install the database packages:
sudo apt-get install postgresql postgresql-contrib
Install Supervisor in order to run Django and Gunicorn as background tasks:
sudo apt-get install supervisor
Enable it:
sudo systemctl enable supervisor
Start it:
sudo systemctl start supervisor
Setting the database Change to database user:
sudo su - postgres
Create a PostgreSQL user (possibly differentiate from the system user):
createuser name_of_db_user
Create its database:
createdb -O name_of_db_user name_of_db
Add a password to the user:
psql -c "ALTER USER name_of_db_user WITH PASSWORD 'the_password'"
Exit the postgres setup:
exit
With that Python 3 dependencies:
sudo apt-get install python3 python3-gi python3-dbus python3-systemd
sudo apt-get install python3-psycopg2 python3-dev
sudo apt-get install libpq-dev
Then Django, psycopg2 and Gunicorn (to
pip3 install django psycopg2 gunicorn
psycopg2 is an adapter to help Python use the PostgreSQL database
Start a Django project:
django-admin startproject name_of_project
Change directory to root project directory (where manage.py is situated, the inside the name_of_project folder created by the last terminal command). Then install Git packages (version-control system for tracking changes in source code during software development), configure your username and email address.
sudo apt-get install git-core
git config — global user.name “username”
git config — global user.email “email_address”
View all Git settings, for now only user settings:
git config — list
Will give you:
user.name=First name Last name user.email=firstname@example.com
Initialise the git repository
git init
Check the repository status
git status
Add a .gitignore file to project root in order to stop git from committing files that are either irrelevant to the project or containing sensitive information, here is a generic file:
Byte-compiled / optimized / DLL files
pycache/ .py[cod] $py.class
C extensions
*.so
Distribution / packaging
.Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ .egg-info/ .installed.cfg .egg MANIFEST
PyInstaller
Usually these files are written by a python script from a template
before PyInstaller builds the exe, so as to inject date/other infos into it.
.manifest .spec
Installer logs
pip-log.txt pip-delete-this-directory.txt
Unit test / coverage reports
htmlcov/ .tox/ .nox/ .coverage .coverage. .cache nosetests.xml coverage.xml .cover .hypothesis/ .pytest_cache/
Translations
.mo .pot
Django stuff:
*.log local_settings.py db.sqlite3
Flask stuff:
instance/ .webassets-cache
Scrapy stuff:
.scrapy
Sphinx documentation
docs/_build/
PyBuilder
target/
Jupyter Notebook
.ipynb_checkpoints
IPython
profile_default/ ipython_config.py
pyenv
.python-version
celery beat schedule file
celerybeat-schedule
SageMath parsed files
*.sage.py
Environments
.env .venv env/ venv/ ENV/ env.bak/ venv.bak/
Spyder project settings
.spyderproject .spyproject
Rope project settings
.ropeproject
mkdocs documentation
/site
mypy
.mypy_cache/ .dmypy.json dmypy.json
Pyre type checker
.pyre/
SQLite database files
*.sqlite3
Add a requirements.txt file to root project (where manage.py is) To do so use pip3 to list all packages added using the package installer:
pip3 freeze
You can also simply run the command below to create or overwrite a requirements.txt files with the packages installed by pip and the version you are using:
pip3 freeze > requirements.txt
Install packages from requirements.txt:
pip3 install -r requirements.txt
Add files and make your first commit:
git add .
git commit -m “add_description”
See this article to check out useful commands when using Git on a daily basis.
In the future you may need to upgrade or delete the packages installed with pip, or even upgrade pip itself. Here are the commands to run:
If some requirements are out of date upgrade them using:
pip3 install --upgrade name_of_package
To upgrade all packages using the requirements.txt list:
pip3 install --upgrade -r requirements.txt
Or uninstall the package using:
pip3 uninstall name_of_package
To upgrade pip:
pip3 install --upgrade pip 메타데이터
- post_id
- e6a4db2c3751
- slug
- part-1-installing-raspbian-setting-up-the-system-and-django-project-and-first-git-commit-e6a4db2c3751
- url
- https://medium.com/@cactegra/part-1-installing-raspbian-setting-up-the-system-and-django-project-and-first-git-commit-e6a4db2c3751
- canonical_url
- https://medium.com/@cactegra/part-1-installing-raspbian-setting-up-the-system-and-django-project-and-first-git-commit-e6a4db2c3751
- author_url
- https://medium.com/@cactegra
- status
- ok
- fetched_at
- 2026-06-17 13:50:26