-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpython
More file actions
153 lines (125 loc) · 3.25 KB
/
python
File metadata and controls
153 lines (125 loc) · 3.25 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/
https://www.fomfus.com/articles/how-to-use-email-as-username-for-django-authentication-removing-the-username/
python -m venv env
--for windows only
.\env\Scripts\activate
--linux/mac
sourc env_name/bin/activate
deactivate
run inside virtual env
pip3 freeze > requirements.txt
pipenv --venv
```
install microsoft python extension
ctrl + shirt + p == Format Document, Select Linter
.vscode-> settings.json {
"python.linting.pylintArgs": [
"--load-plugins=pylint_django",
"--disable=C0111",
"--django-settings-module=<mainapp>.settings"
],
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
},
"python.formatting.provider": "none",
"editor.formatOnSave": true
}
```
```
pip install pre-commit
pre-commit install
.pre-commit-config.yaml
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.7.0
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- repo: https://github.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
default_language_version:
python: python3.8
.flake8
[flake8]
# https://flake8.pycqa.org/en/latest/user/error-codes.html
# https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
select =
F
E
W1 #Indentation warning
W2 #Whitespace warning
W6 #Deprecation warning
N8
ignore = E800
max-line-length = 170
max-complexity = 18
exclude = .git,__pycache__,venv/,migrations/
```
pip list
pip install pipenv
pipenv= pip + virtualenv
pipenv install requests
pipenv --venv
pipenv shell
pipenv graph --list of all installed packeage
pipenv update --outdated --list out the updated package
pipenv update package_name
pipenv install opencv-python
pipenv install django
after install django
run pip freeze and get the install packages
make a requirements.txt file and list down the packages
pipenv shell
django-admin startproject vidly .
python manage.py startapp listings
--------------
python manage.py help
python manage.py createsuperuser
python manage.py runserver
python manage.py collectstatic(make folder named static(anythings) inside root folder)
python manage.py migrate
python manage.py makemigrations
----------------
postgres
-----------
pip install psycopg2
pip install psycopg2-binary
pip install Pillow (for images)
-----------
postgresdb
postgres app
pgadmin
-------------------
pip install pylint-django
.pylintrc file ->> load-plugins=pylint-django
------------------------------
for mysql
--------------
pip install mysqlclient
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydb',
'USER': 'root',
'PASSWORD': 'YOUR_DB_PASSWORD',
'HOST': 'localhost',
'PORT': '3306',
---------------REST------
pipenv install djangorestframework
pipenv shell
pipenv install django-cors-headers
Environment Variable in django
-------------------------------
os.environ.get('variable_name')