DEV Community

Lam Hoang
Lam Hoang

Posted on

2

Django 2 Cheat Sheet

Django Cheat Sheet tries to provide a basic reference for beginner and advanced developers, lower the entry barrier for newcomers, and help veterans refresh the old tricks. Full Django Cheat Sheet

Creating a virtual environment

We need to create a virtual env for our app to run in: More Here
Run this command in whatever folder you want to create your venv folder

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

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (2)

Collapse
 
ale_jacques profile image
Alexandre Jacques

Hi!

Just a little typo: python manage.py start app APPNAME should be startapp (no spaces).

:)

Collapse
 
lamhoanganh profile image
Lam Hoang

Thank Alexander. I fixed it :D

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay