DEV Community

Min Park
Min Park

Posted on

[Python] Django 101

Install

python3 -m venv ./venv
source ./venv/bin/activate

# Escape from venv
deactivate

# Check packages installed in the venv
pip freeze

# Create project & app
pip install django
django-admin startproject PROJECT-NAME
python manage.py start app APP-NAME
Enter fullscreen mode Exit fullscreen mode

Commands

# Run server
python manage.py runserver

# Create migrations
python manage.py makemigrations

# Run migration
python manage.py migrate

# Collect static files
python manage.py collectstatic
Enter fullscreen mode Exit fullscreen mode

Postgres DB setup

sudo -u postgres psql

postgres=# CREATE DATABASE myproject;
postgres=# CREATE USER myprojectuser WITH PASSWORD 'password';
Enter fullscreen mode Exit fullscreen mode

Discussion (0)