Skip to content

Instantly share code, notes, and snippets.

@eloc0n
Last active March 7, 2021 10:16
Show Gist options
  • Save eloc0n/61b35bad9d00a80c7ecb942a65d06fb0 to your computer and use it in GitHub Desktop.
Save eloc0n/61b35bad9d00a80c7ecb942a65d06fb0 to your computer and use it in GitHub Desktop.
Django-command-cheat-sheet

Installing pip for Python 3

To install pip for Python 3 on Ubuntu 20.04 run the following commands as root or sudo user in your terminal:

sudo apt update
sudo apt install python3-pip

When the installation is complete, verify the installation by checking the pip version:

pip3 --version

Let’s start by installing the python3-venv package that provides the venv module.

sudo apt install python3-venv

Creating a virtual environment

Before we do anything else we'll create a new virtual environment, using venv. This will make sure our package configuration is kept nicely isolated from any other projects we're working on.

python3 -m venv env

Activate the virtualenv

source env/bin/activate

Escape from venv

deactivate

Check packages installed in that venv

pip freeze

Now that we're inside a virtual environment, we can install our package requirements.

pip install django
pip install djangorestframework

Create your project

django-admin startproject PROJECTNAME

Run Server (http://127.0.0.1:8000) CTRL+C to stop

python manage.py runserver

Create an app

python manage.py start app APPNAME

Create migrations

python manage.py makemigrations

Run migration

python manage.py migrate

Collect Static Files

python manage.py collectstatic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment