Created
December 22, 2022 19:52
-
-
Save madhikarma/3e5eedfca94ff2939b53b3dc7531b1ee to your computer and use it in GitHub Desktop.
Python Django Cheatsheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from https://dev.to/ericchapman/my-beloved-django-cheat-sheet-2056 | |
# Create et access project folder | |
~$ mkdir project_name | |
~$ cd project_name | |
# Create Python virtual env | |
~$ python3 -m venv venv | |
# Activate virtual env | |
~$ source venv/bin/activate | |
# If you want to deactivate virtual env | |
~$ deactivate | |
# Install django (~= same as 3.1.*) | |
~$ pip install django~=3.1.0 | |
# New django project (from project_name folder) | |
~$ django-admin startproject config . | |
# Create app (from project_name folder) | |
~$ python manage.py startapp app_name | |
~$ python manage.py makemigrations | |
Migrate: Will read the migrations files and create the actual database and tables | |
~$ python manage.py migrate | |
Create superuser for authenficiation/admin panel | |
~$ python manage.py createsuperuser | |
Start server | |
~$ python manage.py runserver => ex. http://127.0.0.1:8000 | |
Requirements | |
# Create a requirements file that contain all your projet dependencies | |
~$ pip freeze > requirements.txt | |
# Install your project requirements (if a requirements file exist) | |
~$ pip install -r requirements.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment