- Create a virtual environment.
python3 -m venv env_name
- Activate Virtual environment.
# macos
source env_name/bin/activate
- Install dependencies.
pip install django djangorestframework
- Create a django project.
python django-admin startproject *project_name*
- Create a django app.
cd *project_name*
python manage.py startapp *app_ma,e*
- Run the django project.
python manage.py runserver 0.0.0.0:8000 # you can use any port here, i'm mr 8000 <3
Bonjour! your first django up and running...
Smash me to show-up
- cd into the base directory of your project.
cd /where/you/want/to/go
- Initialize git repository.
git init
- Add files that are going to be included in first commit.
# git add single file
git add *file_name*
# git add everything inside current directory
git add .
- Create a commit
git commit -m 'initial commit'
-
Create github repository.
-
Add remote link to your project.
git remote add origin https://github.com/your/project.git
- Create main branch
git branch -M main
- push to github.
git push -u origin main
- Add
.gitignore
file.
# macos
touch .gitignore
- Add directories or files which are not going to pushed to github.
dir/
__pycache__/ # ignone pycache directory
*.pyc # ignore all py cache files
*.sqlite3 # ignore database file
cclick here to expand
- Create a
launch.json file
mkdir .vscode
cd .vscode
touch launch.json
- Add following content to the
launch.josn
.
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Django",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/backend/manage.py", // location for manage.py file
"args": [
"runserver",
"5000" // specify the port
],
"django": true
}
]
}
- Add python interpreter location to vs code.
- press
command
+P
. - Type
>
on the text section appear very top of the IDE. - Click on
Python: Select Interpreter
. - Enter python executable location there.(vnev python location)
ex: ~/Desktop/projects/my_app/venv/bin/python