์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- vscode ์์ค์ ์ด
- {'error': {'errorcode': '200'
- ํ์ด์ฌ๋ฒ์ ์ฌ๋ฌ๊ฐ
- ํ์ด์ฌ ์ค์น๊ฒฝ๋ก ๋ณ๊ฒฝ
- ๋งฅ๋ถํ์ด์ฌ์ฌ๋ฌ๋ฒ์
- ํ์ด์ฌ๋ฒ์ ๋ณ๊ฒฝ
- ncp authentication failed
- codebuild no matching artifact paths found
- ์ค๋ธ์
- codebuild cliend_error
- command did not exit successfully docker-compose -f docker-compose.yml build exit status 1
- vscode๋ฌดํ๋ก๋ฉ
- rds ํ๋ผ๋ฏธํฐ๊ทธ๋ฃน
- ํ์ด์ฌ์ฌ๋ฌ๋ฒ์ ๋ณ๊ฒฝ
- vscode์๊ณ์์ด์ฝ
- 'details': 'invalid authentication information.'}}
- vscode์์ค์ ์ด ๋ฌดํ๋ก๋ฉ
- ncp api ์๋ต์ค๋ฅ
- rds character_set ๋ณ๊ฒฝ
- ncp 401 authentication failed
- ํฐ์คํ ๋ฆฌ์ฑ๋ฆฐ์ง
- 'message': 'authentication failed'
- ํ์ด์ฌ ๊ฒฝ๋ก ์์
- codepipeline ์ค๋ฅ
- fcm multicast
- fcm push
- fcm ๋ฉํฐํธ์
- rds utf8mb4 ๋ณ๊ฒฝ
- ๋ค์ด๋ฒํด๋ผ์ฐ๋ authentication failed
- route53 ์๋ธ๋๋ฉ์ธ
- Today
- Total
All that I've dreamed of
Django + debug_toolbar ์ฌ์ฉํ๊ธฐ (+ Docker ํ๊ฒฝ์ ์ถ๊ฐ) ๋ณธ๋ฌธ
๐ Django + debug toolbar ์ฌ์ฉํ๊ธฐ
๐ Docker ํ๊ฒฝ์์ Django + debug toolbar ์ฌ์ฉํ๊ธฐ
1. Django + debug toolbar ์ฌ์ฉํ๊ธฐ
โ๏ธ์ฐธ๊ณ : https://django-debug-toolbar.readthedocs.io/en/latest/installation.html
poetry add django-debug-toolbar
๋๋
pip install django-debug-toolbar
Installed-Apps ์ "django.contrib.staticfiles" ์ด ๋ค์ด์๋์ง ํ์ธ (๋ํดํธ๋ก ๋ค์ด๊ฐ ์์)
โ๏ธ STATIC_URL = "static/" ์๋์ง ํ์ธ
INSTALLED_APPS = [
# ...
"django.contrib.staticfiles",
# ...
]
โ๏ธ TEMPLATES ํ์ธ
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
# ...
}
]
โ๏ธ INSTALLED_APPS์ debug_toolbar ์ถ๊ฐ
INSTALLED_APPS = [
# ...
"debug_toolbar",
# ...
]
โ๏ธ ๋ฃจํธ์ฑ urls.py ์ ์๋ ์ฃผ์ ์ถ๊ฐ
# config/urls.py
from django.urls import include, path
urlpatterns = [
# ...
path('__debug__/', include('debug_toolbar.urls')),
]
โ๏ธ ๋ฏธ๋ค์จ์ด ์ถ๊ฐ
MIDDLEWARE = [
# ...
"debug_toolbar.middleware.DebugToolbarMiddleware",
# ...
]
โ๏ธ INTERNAL_IPS ์ถ๊ฐ
INTERNAL_IPS = ['127.0.0.1']
์๋ง Docker ํ๊ฒฝ์ด ์๋๋ผ๋ฉด 127.0.0.1:8000 ์ผ๋ก ์ ์ํ์ ๋ Debug toolbar ๊ฐ ์ ๋ณด์ผ ๊ฑฐ์์
But... 1๋ฒ๊ณผ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ์ธํ ์ ํด๋ Docker ํ๊ฒฝ์์๋ debug tool bar๊ฐ ๋ณด์ด์ง ์์ต๋๋ค.
๐ก ์ Docker ํ๊ฒฝ์์๋ debug tool bar ๊ฐ ๋ณด์ด์ง ์์๊น์..?
โ๏ธ ์ฐธ๊ณ Django Debug Toolbar not showing up when using Docker โ Django & Docker
Django Debug Toolbar not showing up when using DockerโโโDjango & Docker
The solution to why Django Debug Toolbar does not show up when using Docker.
ranjanmp.medium.com
- INTERNAL_IPS ๋์...
Debug toolbar ๋ INTERNAL_IPS ๋ผ๋ ์ค์ ์ด ์์ต๋๋ค.
Debug toolbar ๋ ์ ์ ๊ฐ ์ ๊ทผํ๋ ค๋ ์ ํ๋ฆฌ์ผ์ด์ IP ์ฃผ์๊ฐ INTERNAL_IPS ์ ๋ฑ๋ก๋ ๊ฒฝ์ฐ์๋ง ๋ํ๋๊ฒ ๋ฉ๋๋ค.
์ด๊ฑด ๋ณด์์ ์ธก๋ฉด์์ ๋ค๋ฅธ IP ์ฃผ์๊ฐ Debug toolbar ์ ์ ๊ทผํ์ง ๋ชปํ๊ฒ ํ๊ธฐ ์ํด์ ์ธ๋ฐ์.
๊ฐ๋ฐ์๋ INTERNAL_IPS ์ IP์ฃผ์๋ฅผ ์ถ๊ฐํด์ Debug toolbar์ ์ ๊ทผํ ์ ์์ด์.
๋ก์ปฌ ๊ฐ๋ฐํ๊ฒฝ์์ INTERNAL_IPS ๋ ['127.0.0.1']๋ก ์ธํ ๋์ด ์์ด์ผ ํฉ๋๋ค.
- ๊ทธ๋์ ์ Dockerํ๊ฒฝ์์๋ ์ ๋ณด์ด๋๋ฐ์...
๊ฐ๊ฐ์ Docker ์ปจํ ์ด๋๋ Docker bridge network๋ก๋ถํฐ IP ์ฃผ์๋ฅผ ํ ๋น ๋ฐ๊ฒ๋ฉ๋๋ค.
์ฌ๋ฌ๊ฐ์ ๋ฉํฐ ์ปจํ ์ด๋๊ฐ docker-compose๋ฅผ ํตํด ์คํ๋ ๋, docker-compose ๋ด์ ์๋ ๋ชจ๋ ์ ํ๋ฆฌ์ผ์ด์ ๋ค์ ์ํด ๊ธฐ๋ณธ ์๋ธ๋ท ๋ง์คํฌ์ ๊ฒ์ดํธ์จ์ด๋ก ์๋ก์ด ๋คํธ์ํฌ๊ฐ ์์ฑ๋ฉ๋๋ค.
์ด ์๋ก์ด ๋คํธ์ํฌ๋ ๊ธฐ๋ณธ์ ์ผ๋ก '<ํด๋์ด๋ฆ>_default' ๋ผ๋ ์ด๋ฆ์ ๊ฐ๊ฒ ๋๋๋ฐ์, ๋ง์ฝ ๋คํธ์ํฌ ์ด๋ฆ์ด docker-compose ํ์ผ์ ๋ช ์๋์ด ์์ง ์์ผ๋ฉด '<ํด๋์ด๋ฆ>'์ docker-compose ํ์ผ ๋ด์ ํด๋, ๋๋ ํฐ๋ฆฌ ์ด๋ฆ ์ค ํ๋๊ฐ ๋ฉ๋๋ค.
์ปจํ ์ด๋์ ์์ฒญ(request)๋ Docker bridge network ์ ๊ฒ์ดํธ์จ์ด๋ฅผ ํตํ๊ฒ ๋ฉ๋๋ค. (docker-compose ๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ..)
๋ก์ปฌ ํธ์คํธ์์ ์์๋ ์์ฒญ์ ๋คํธ์ํฌ์ ๊ฒ์ดํธ์จ์ด๋ฅผ ํตํด ์ ๋ฌ๋๋ฏ๋ก Django ์ ํ๋ฆฌ์ผ์ด์ ์ ์์ฒญ๋ฐ์ IP ์ฃผ์๋ฅผ Docker ๋คํธ์ํฌ์ ๊ฒ์ดํธ์จ์ด IP ์ฃผ์๋ก ์ธ์ํ๊ฒ ๋ฉ๋๋ค. ๊ฒฐ๊ตญ ๋ก์ปฌ์์ ๊ฐ๋ฐ์ค์ผ ๋ INTERNAL_IPS๋ฅผ ["127.0.0.1"] ์ด๋ผ๊ณ ์ค์ ํ๋๋ผ๋ Debug toolbar๊ฐ ๋ํ๋์ง ์๋ ์ด์ ์ ๋๋ค. (๊ฒ์ดํธ์จ์ด ์ฃผ์๋ 127.0.0.1์ด ์๋๋๊น์...)
์ฆ, ๊ฒ์ดํธ์จ์ด์ IP ์ฃผ์๋ฅผ INTERNAL_IPS์ ์ถ๊ฐํ๋ฉด Debug toolbar ๋ ๋ณด์ด๊ฒ ๋ ๊ฑฐ์์.
ํ์ง๋ง ์ด๋ ๊ฒ ํ๋์ฝ๋ฉํ๋ ๋ฐฉ์์ ์ถ์ฒํ์ง ์์ต๋๋ค.
์๋ํ๋ฉด ๊ฒ์ดํธ์จ์ด IP ์ฃผ์๋ ์๋ก์ด ์ด๋ฏธ์ง๊ฐ ๋น๋๋๊ณ , ์ปจํ ์ด๋๊ฐ ์ค์ง๋๊ณ , ์ญ์ ๋๊ณ , ๋ค์ ์์๋ ๋๋ง๋ค ๋ฐ๋ ์ ์๊ธฐ ๋๋ฌธ์ด์์.
2. Docker ํ๊ฒฝ์์ debug tool bar ์ฌ์ฉํ๊ธฐ
โ๏ธ Prerequisite
- Static, Template, Middleware, url.py ์ ์ค์ ์ 1๋ฒ๊ณผ ๊ฐ์ด ๋ง์ณค๋ค๋ ์ ์ ํ์ INTERNAL_IPS ๋ง ๋ณ๊ฒฝํด ๋ณผ๊ฒ์!
# settings.py
INTERNAL_IPS = ['127.0.0.1'] # ๊ธฐ์กด์ INTERNAL_IPS
if DEBUG:
import socket
hostname, _, ips =socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS += [ip[:-1] + '1' for ip in ips]
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
=> ํธ์คํธ ๋จธ์ ์ IP ์ฃผ์๋ฅผ ips ํ๋ผ๋ฏธํฐ์ ๋ฆฌํดํฉ๋๋ค
[ip[:-1] + '1' for ip in ips]
=> ํธ์คํธ IP ์ฃผ์์ ๋ง์ง๋ง ํ ์๋ฆฌ๋ฅผ ์ ๊ฑฐํ๊ณ 1๋ก ๋์ฒดํฉ๋๋ค.
์๋ฅผ ๋ค์ด ํธ์คํธ ๋จธ์ ์ IP ์ฃผ์๊ฐ 172.17.0.3 ์ผ ๊ฒฝ์ฐ, Docker ๋คํธ์ํฌ์ ๊ฒ์ดํธ์จ์ด IP ์ฃผ์๋ ํญ์ 172.17.0.1์ด ๋๊ธฐ ๋๋ฌธ์ด์์.
print(INTERNAL_IPS) ๋ฅผ ์ถ๋ ฅํด๋ณด์์ต๋๋ค.

๊ธฐ์กด์ '127.0.0.1' ์ ๊ฒ์ดํธ์จ์ด IP ์ฃผ์๊ฐ ์ถ๊ฐ๋์ด ์ถ๋ ฅ๋๋ ๊ฑธ ๋ณผ ์ ์์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ ...

Debug toolbar ๊ฐ ์ ๋์ค๋ ๊ฑธ ๋ณผ ์ ์๋ต๋๋น ๐๐๐
์ ๊ฐ ํ ๋ฐฉ์์ผ๋ก๋ ์ ์ ๋๋ค๋ฉด ์๋ ์ฐธ๊ณ ๋งํฌ๋ค๋ ํ์ธํด ๋ณด์ธ์><
โ๏ธ ์ฐธ๊ณ django_debug_toolbar and Docker
https://stackoverflow.com/questions/26898597/django-debug-toolbar-and-docker
โ๏ธ ์ฐธ๊ณ Fix: Django Debug Toolbar not showing when using with Docker.
https://gist.github.com/douglasmiranda/9de51aaba14543851ca3