Creating a Django Project on Linux

Step 1: Download Python

sudo apt-get update
sudo apt-get install python3.8
python3 --version -> Python 3.8.5 hopefully

Step 2: Create Virtual Environment and Install Django

python3 -m venv myvenv
source myvenv/bin/activate

Step 3: Upgrade PIP and install Django

python -m pip install --upgrade pip
echo 'Django~=3.2.3' >> myvenv/requirements.txt
pip install -r myvenv/requirements.txt

Step 4: Install and Configure PostgreSQL

sudo apt-get update
sudo apt-get install postgresql-12

Step 5: Create Django Project

django-admin startproject supercoolproject
python manage.py runserver

Step 6: Add Modules

cd ~/venvs/django-fantasy-hockey
Django~=3.2.3
django-environ
psycopg2
Django~=3.2.3
django-environ
djangorestframework
markdown
django-filter
psycopg2
requests
pip install -r myvenv/requirements.txt

Step 7: Configure settings.py and .env file

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
]
from pathlib import Path
import environ
env = environ.Env()
environ.Env.read_env()
SECRET_KEY=<YOUR SECRET KEY>
DATABASE_NAME=<YOUR DATABASE NAME>
DATABASE_USER=<YOUR DATABASE USER>
DATABASE_PASSWORD=<YOUR DATABASE PASSWORD>
DATABASE_HOST=/var/run/postgresql
DATABASE_PORT=5432
SECRET_KEY = env('SECRET_KEY')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': env('DATABASE_NAME'),
'USER': env('DATABASE_USER'),
'PASSWORD': env('DATABASE_PASSWORD'),
'HOST': env('DATABASE_HOST'),
'PORT': env('DATABASE_PORT')
}
}

Step 8: Create a .gitignore and Push to GitHub

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Weeknotes Series 12, Chapter 1

Routes in Rails

A Cross-platform Console Selenium Project

Copy/Paste in Quick Look on MacOS

before

CSS Box Model for Beginner: Unlocking the Magic of CSS

When a paper plane scales up to a Boeing 747 — escalation problems for a network

Unveiling the new Pixie Labs website

Apache Kafka — 101 & How It Comes to Picture

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Seth Massarsky

Seth Massarsky

More from Medium

Automation And Django Debug

Hyper-V: Setting Up Best Experience From Ubuntu 20.04 VM (Easy Step-By-Step Tutorial)

Get Started with Django in 5 min

Introduction To Python..!