@@ -4,40 +4,39 @@ Create Virtual Environment
44
55- if windows
66
7- ``` bash
8- python -m venv .venv
9- ```
7+ ``` bash
8+ python -m venv .venv
9+ ```
1010
1111- if mac or linux
1212
13- ` ` ` bash
14- python3 -m venv .venv
15- ` ` `
13+ ``` bash
14+ python3 -m venv .venv
15+ ```
1616
1717Activate Virtual Environment
1818
1919- if windows
2020
21- ` ` ` bash
22- source .venv/Scripts/activate
23- ` ` `
24-
21+ ``` bash
22+ source .venv/Scripts/activate
23+ ```
2524
2625- if mac or linux
2726
28- ` ` ` bash
29- source .venv/bin/activate
30- ` ` `
27+ ``` bash
28+ source .venv/bin/activate
29+ ```
3130
3231- if you want to deactivate
3332
34- ` ` ` bash
35- deactivate
36- ` ` `
33+ ``` bash
34+ deactivate
35+ ```
3736
3837Install Django
39-
40- ` ` ` bash
38+
39+ ``` bash
4140pip install django
4241```
4342
@@ -56,218 +55,214 @@ python manage.py runserver
5655Setup Pylint
5756
5857- Reference Links
59-
60- - [pylint](https://github.com/PyCQA/pylint/)
6158
62- - [pylint-django ](https://github.com/PyCQA/pylint-django /)
59+ - [ pylint] ( https://github.com/PyCQA/pylint/ )
6360
64- - Blog: [How to setup pylint for django project ](https://dkolodzey.medium. com/pylint-django-with-github-actions-2e3ef05dd34a )
61+ - [ pylint- django] ( https://github. com/PyCQA/ pylint-django/ )
6562
63+ - Blog: [ How to setup pylint for django project] ( https://dkolodzey.medium.com/pylint-django-with-github-actions-2e3ef05dd34a )
6664
6765- Install pylint for code analysis and linting
6866
69- ` ` ` bash
70- pip install pylint
71- ` ` `
67+ ``` bash
68+ pip install pylint
69+ ```
7270
7371- Install pylint-django pylint plugin
7472
75- ` ` ` bash
76- pip install pylint-django
77- ` ` `
73+ ``` bash
74+ pip install pylint-django
75+ ```
7876
7977- Create pylint config file if you want to customize
8078
81- ` ` ` bash
82- pylint --generate-rcfile > .pylintrc
83- ` ` `
79+ ``` bash
80+ pylint --generate-rcfile > .pylintrc
81+ ```
8482
8583<!-- - Or use [google style guide](https://google.github.io/styleguide/pyguide.html)
8684
8785 [pylintrc file](https://google.github.io/styleguide/pylintrc) -->
8886
8987- Add pylint_django in load-plugins to pylint config file
9088
91- ` ` ` text
92- [MASTER]
93- load-plugins=pylint_django
94- ` ` `
89+ ``` text
90+ [MASTER]
91+ load-plugins=pylint_django
92+ ```
9593
9694- Add django settings module in pylint config file
9795
98- ` ` ` text
99- [pylint-django]
100- django-settings-module=< project_name> .settings
101- ` ` `
96+ ``` text
97+ [pylint-django]
98+ django-settings-module=<project_name>.settings
99+ ```
102100
103101- Run pylint
104102
105- ` ` ` bash
106- pylint ** /* .py
107- ` ` `
103+ ``` bash
104+ pylint ** /* .py
105+ ```
108106
109- - NOTE: if you not want to create pylint config file, you can run pylint with
107+ - NOTE: if you not want to create pylint config file, you can run pylint with
110108
111109``` bash
112110pylint --load-plugins=pylint_django --django-settings-module=< project_name> .settings ** /* .py
113111```
114112
115113TODO - Fix this is not working
116- - If you are using vscode, you can install pylint extension and it will automatically run pylint on save. for that you need to add this in settings.json
117114
118- ` ` ` json
119- {
120- {
121- " python.linting.enabled" : true,
122- " python.linting.pylintEnabled" : true,
123- " python.linting.pylintArgs" : [
124- " --load-plugins" ,
125- " pylint_django" ,
126- " --django-settings-module=<project_name>.settings"
127- ]
128- }
129- ` ` `
115+ - If you are using vscode, you can install pylint extension and it will automatically run pylint on save. for that you need to add this in settings.json
130116
131- [Setup Reference Links](https://dkolodzey.medium.com/pylint-for-django-in-vscode-f3fadb8462d)
117+ ``` json
118+ {
119+ {
120+ "python.linting.enabled" : true ,
121+ "python.linting.pylintEnabled" : true ,
122+ "python.linting.pylintArgs" : [
123+ " --load-plugins" ,
124+ " pylint_django" ,
125+ " --django-settings-module=<project_name>.settings"
126+ ]
127+ }
128+ ```
129+
130+ [Setup Reference Links ](https://dkolodzey.medium.com/pylint-for-django-in-vscode-f3fadb8462d)
132131
133132Setup Black for code formatting
134133
135134- Reference Links
136-
135+
137136 - [black](https://black.readthedocs.io/en/stable/)
138137 - [Blog Link](https://ctrlzblog.com/how-to-set-up-black-to-automatically-format-your-django-project/)
139138
140139- Install black
141140
142- ` ` ` bash
143- pip install black
144- ` ` `
141+ ```bash
142+ pip install black
143+ ```
145144
146145- Run black
147146
148- ` ` ` bash
149- black .
150- ` ` `
147+ ```bash
148+ black .
149+ ```
151150
152151- Check black formatting
153152
154- ` ` ` bash
155- black --check .
156- ` ` `
153+ ```bash
154+ black --check .
155+ ```
157156
158- - If you are using vscode, you need to add this in settings.json
157+ - If you are using vscode
159158
159+ - Install VS Code Extension `ms-python.black-formatter`
160+
161+ - add this in settings.json
160162 ```json
161163 {
162- " editor.formatOnSave" : true,
163- " python.formatting.provider" : " black" ,
164+ "editor.formatOnSave" : true ,
165+ "python.formatting.provider" : " black"
164166 }
165167 ```
166-
168+
167169Setup mypy for static type checking
168170
169171- Reference Links
170-
172+
171173 - [mypy](https://mypy.readthedocs.io/en/stable/)
172174 - [django-stubs github repo](https://github.com/typeddjango/django-stubs)
173175
174176- Install mypy
175-
177+
176178 ```bash
177179 pip install mypy
178180 ```
179181
180182- Install django-stubs for django type checking
181-
183+
182184 ```bash
183185 pip install django-stubs
184186 ```
185187
186188- Note this is not required in current case, but if you are using django models, you need to install django-stubs
187- - [mypy config docs](https://mypy.readthedocs.io/en/latest/config_file.html)
188- - [Stack Overflow Reference](https://stackoverflow.com/questions/59031982/type-annotations-for-django-models)
189-
190- - Add django-stubs in plugins in mypy config file ` mypy.ini`
191-
192- ` ` ` text
193- [mypy]
194- plugins = mypy_django_plugin.main
195- ` ` `
196189
197- - Add django settings module in mypy config file ` mypy.ini`
198-
199- ` ` ` text
200- [mypy.plugins.django-stubs]
201- django_settings_module = < project_name> .settings
202- ` ` `
190+ - [mypy config docs](https://mypy.readthedocs.io/en/latest/config_file.html)
191+ - [Stack Overflow Reference](https://stackoverflow.com/questions/59031982/type-annotations-for-django-models)
203192
204- - Run mypy
205-
206- ` ` ` bash
207- mypy .
193+ - Add django-stubs in plugins in mypy config file `mypy.ini`
208194
195+ ```text
196+ [mypy ]
197+ plugins = mypy_django_plugin.main
209198 ```
210199
200+ - Add django settings module in mypy config file `mypy.ini`
201+ ```text
202+ [mypy.plugins.django-stubs ]
203+ django_settings_module = <project_name>.settings
204+ ```
205+
206+ - Run mypy
207+
208+ ```bash
209+ mypy .
210+
211+ ```
211212
212213- If you are using vscode, you need to add this in settings.json
213214
214- ` ` ` json
215- {
216- " python.linting.mypyEnabled" : true,
217- " python.linting.mypyArgs" : [
218- " --strict" ,
219- ]
220- }
221- ` ` `
215+ ```json
216+ {
217+ "python.linting.mypyEnabled" : true ,
218+ "python.linting.mypyArgs" : [" --strict" ]
219+ }
220+ ```
222221
223222- [Reference Blog](https://dev.to/jodaut/python-type-checking-with-visual-studio-code-46a7)
224223
225224Setup isort for sorting imports
226225
227226- Reference Links
228-
229- - [isort](https://pycqa.github.io/isort/)
230- - [github wiki](https://github.com/PyCQA/isort/wiki/isort-Settings)
227+
228+ - [isort](https://pycqa.github.io/isort/)
229+ - [github wiki](https://github.com/PyCQA/isort/wiki/isort-Settings)
231230
232231- Install isort
233-
234- ` ` ` bash
235- pip install isort
236- ` ` `
232+
233+ ```bash
234+ pip install isort
235+ ```
237236
238237- Run isort
239-
240- ` ` ` bash
241- isort .
242- ` ` `
238+
239+ ```bash
240+ isort .
241+ ```
243242
244243- Check isort
245244
246- ` ` ` bash
247- isort --check .
248- ` ` `
245+ ```bash
246+ isort --check .
247+ ```
249248
250249- If want to customize isort, you can create isort config file `isort.cfg`
251250
252- ` ` ` text
253- [settings]
254- verbose = true
255- skip_glob = ** /migrations/* .py
256- ` ` `
251+ ```text
252+ [settings ]
253+ verbose = true
254+ skip_glob = **/migrations/*.py
255+ ```
257256
258257- NOTE: supported options are [here](https://pycqa.github.io/isort/docs/configuration/options.html)
259258
260-
261259- If you are using vscode, you need to add this in settings.json
262260
263- ` ` ` json
264- {
265- " editor.codeActionsOnSave" : {
266- " source.organizeImports" : true
267- },
268- " isort.args" : [
269- " skip_glob" ,
270- " */migrations/*" ,
271- ],
272- }
273- ` ` `
261+ ```json
262+ {
263+ "editor.codeActionsOnSave" : {
264+ "source.organizeImports" : true
265+ },
266+ "isort.args" : [" skip_glob" , " */migrations/*" ]
267+ }
268+ ```
0 commit comments