Skip to content

django3(docker) remote debug with vscode sample project

Notifications You must be signed in to change notification settings

katsuya-n/pub_docker_django

Repository files navigation

django3(docker) remote debug with vscode

summary

This is a standard django project. It has already completed django tutorial part 1. Docker-compose is refer to official docker quickstart. In addition, you can use remote debug with vscode. Please check this note.

more details(dev.to)

Remote Debug Django3(Docker) with VSCode

version

  • mysql 5.7
  • python 3.9
  • django 3

start project

$ make build

$ make up

※ If you can't create database called django_sample, you should try to exec make init-db, make stop and make up again.

Open url http://127.0.0.1:8000/polls

Show Hello, world. You're at the polls index.

remote debug with vscode

Use python library ptvsd

install Python extension for Visual Studio Code

Install vscode python library.

python extension

Reopen vscode after install.

open pub_docker_django/ in current directory with vscode

.
├── .vscode
├── Dockerfile
├── Makefile
├── README.md
├── composeexample
├── docker-compose.yml
├── manage.py
├── mysql
├── polls
└── requirements.txt

start docker container

$ make up

check break point

break point

Attention! Break point can't seem to use some of other files(etc. polls/url.py, manage.py ...). Sorry, I don't know the reason.

remove comment out

Remove comment out L23 after make up.

Attention! docker container can't start if you remove comment out before make up

ptvsd.enable_attach(address=('0.0.0.0', 3000))

comment out

start debug

Enter fn + F5(Mac OS). Under bar color changes from blue to orange.

start debug

Reload http://127.0.0.1:8000/polls/, and program will stop break point.

stop break point

About

django3(docker) remote debug with vscode sample project

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published