APP工程師不務正業之Server開發2
Server Architecture
Development IDE, Language & Framework
PyCharm
Python
Django
Development Environment Setup
Install Docker
https://docs.docker.com/desktop/mac/install/Install Python
https://www.python.org/downloads/
Currently I am using Python 3.91
python3 --version
Install pip
1
2curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.pyInstall Django
Currently I am using Django 3.2.41
pip install Django==3.2.4
1
django-admin --version
Install Virtual Env
1
brew install virtualenv
Create Virtual Env
- Create virtual environment
Create a project folder. Create virtual environment in the project folder.1
virtualenv venv --python=python3.9
- Enter virtual environment
1
source ./venv/bin/activate
- Exit virtual environment
1
deactivate
Create Django Project & App
- Create Django project
1
django-admin startproject maochun_test
- Create Django App
1
django-admin startapp user
- Django project structure
Install Python Packages
- Django
- djangorestframework
- drf-yasg
- psycopg2-binary
Run server in local
1 | python manage.py makemigrations |
Others
Generate installed package list
1
pip freeze > requirements.txt
Install package from list
1
pip install -r requirements.txt
Django Settings
https://docs.djangoproject.com/en/4.1/ref/settings/
Common Settings
DB Settings
Installed APP Settings
Middleware Settings
Static Settings
Template Settings
REST Framework Settings
https://www.django-rest-framework.org/api-guide/settings/
Django AdminSite
https://docs.djangoproject.com/en/4.1/ref/contrib/admin/
Django Management Command
https://docs.djangoproject.com/en/4.1/howto/custom-management-commands/
Database & Caching
- PostgreSQL
- Redis
Reference
Comment