Skip to content

Instantly share code, notes, and snippets.

@Sulaymon333
Last active November 21, 2020 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sulaymon333/fa43daaa449db49972cbdb35d860ab6d to your computer and use it in GitHub Desktop.
Save Sulaymon333/fa43daaa449db49972cbdb35d860ab6d to your computer and use it in GitHub Desktop.

Django 2.x Cheat Sheet

Creating a virtual environment

In order to create a django project, it is recommended to create a virtual env for our app to run in: More Here. Navigate to your project folder and run the command below

python -m venv ./venv

Activate the virtualenv

# Mac/Linux
source ./venv/bin/activate

# Windows
venv\Scripts\activate.bat - May need to add full path (c:\users\....venv\Scripts\activate.bat)

Escape from venv

deactivate

Check packages installed in that venv

pip freeze

Install Django

pip install django

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 startapp 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