DEV Community

Cover image for Running python django site
ILshat Khamitov
ILshat Khamitov

Posted on

Running python django site

Installing python and all the required libraries

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib -y
sudo apt-get install python-pip python-dev build-essential -y
sudo apt-get install libpq-dev -y
sudo pip install --upgrade pip
sudo pip install --upgrade virtualenv

Creating a project

mkdir mysite && cd mysite
virtualenv venv
source venv / bin / activate
pip install django-toolbelt
django-admin.py startproject mysite.
echo "web: gunicorn mysite.wsgi"> Procfile
pip freeze> requirements.txt
echo "venv"> .gitignore
git init
git add.
git commit -m "First Commit for Mysite"

Launch site

virtualenv venv
source venv / bin / activate
export $ (cat .env)
pip install -r requirements.txt
python manage.py collectstatic --noinput
gunicorn project.wsgi -b 0.0.0.0:5000

Working with the migrations in Django

python manage.py migrate
python manage.py makemigrations
python manage.py makemigrations --empty yourappname

Working with a list of required packages

pip freeze> requirements.txt
pip install -r requirements.txt

Creating an application

django-admin.py startapp myapp app / myapp

Discussion (0)