Use Docker-Compose to help Django Development

cd ~

mkdir practice_folder

#create a virtualenv

python -m venv .venv

.venv\scripts\activate.bat

pip install django~=4.0.0 psycopg2-binary~=2.9.9

django-admin startproject django_project .

python manage.py runserver 0.0.0.0:8000

pip freeze > requirements.txt

create a Dockfile

create docker-compose.yml

docker-compose up -d –build

vim django_project/settings.py

In the Windows Host Computer Modify django source code and

  • docker-compose.exe web python manage.py startapp accounts
  • docker-compose.exe web python manage.py makemigrations accounts
  • docker-compose.exe web python manage.py migrate
  • docker-compose.exe web python manage.py createsuperuser
  • …………
分類: Django。這篇內容的永久連結

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *