Skip to content

Commit

Permalink
Merge pull request #408 from sparcs-kaist/fix/debug-toolbar
Browse files Browse the repository at this point in the history
Show debug toolbar always
  • Loading branch information
injoonH committed Aug 10, 2023
2 parents c42bfdf + b0bf91c commit 9ca99c5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
15 changes: 14 additions & 1 deletion ara/settings/dev/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import socket
from datetime import datetime, timezone

from ara.settings import INSTALLED_APPS, LOGGING, MIDDLEWARE
Expand All @@ -12,7 +13,7 @@
"http://localhost",
]

CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_ALL_ORIGINS = True

SSO_IS_BETA = False

Expand All @@ -29,6 +30,18 @@
"debug_toolbar_force.middleware.ForceDebugToolbarMiddleware",
]

# https://django-debug-toolbar.readthedocs.io/

_, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + [
"127.0.0.1",
"10.0.2.2",
]

DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK": lambda _: True,
}

REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] = (
"rest_framework.authentication.BasicAuthentication",
"ara.authentication.CsrfExemptSessionAuthentication",
Expand Down
7 changes: 0 additions & 7 deletions ara/settings/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,8 @@

STATIC_URL = "/static/"


# https://django-debug-toolbar.readthedocs.io/

INTERNAL_IPS = ("127.0.0.1",)

if env("DJANGO_ENV") == "development":
INTERNAL_IPS = type(str("c"), (), {"__contains__": lambda *a: True})()


SESSION_ENGINE = "django.contrib.sessions.backends.db"
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SECURE = True
Expand Down
4 changes: 4 additions & 0 deletions ara/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@

CELERY_TASK_ALWAYS_EAGER = True
ELASTICSEARCH_INDEX_NAME = "articles_test"

DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK": lambda _: False,
}
5 changes: 1 addition & 4 deletions ara/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@
),
]

# installed apps (test environment)
if settings.DEBUG:
import debug_toolbar

urlpatterns += [
path("__debug__/", include(debug_toolbar.urls)),
path("api/__debug__/", include("debug_toolbar.urls")),
]

0 comments on commit 9ca99c5

Please sign in to comment.