-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDjango.py
39 lines (26 loc) · 1.48 KB
/
Django.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#######################################
#
# DJANGO CHEAT SHEET
#
#######################################
#**************************************
# Table of Contents
#**************************************
# 1. Python Commands
# 2. Python Shell Commands
#**************************************
# Pyhon Commands (in Project)
#**************************************
python manage.py startapp <App Name> # Create a new app within dir
python manage.py createsuperuser # Creates a user for admin
pyhton manage.py migrate # Performs sync of app models with db
pyhton manage.py makemigrations <App Name> # Detect changes in specified App & create a migration
python manage.py sqlmigrate <App Name> <Migration id> # View Migration Details
#**************************************
# Python Shell Command
#**************************************
pyhton manage.py shell # Boots up shell
from <App Name>.models import <modelName>,<modelName1>,... # Display contents of models from database
<modelName>.objects.all() # Display all insatnces of Model from database
<modelName>.objects.filter(<search params>) # Display all instacnces of Model from database filterd. search params e.g (id = 1, arrib__startswith = 'anyText')
exit() # Quit shell