Add django browser reload for dev

This commit is contained in:
Gabriel Augendre 2022-10-30 10:56:10 +01:00
parent 07d9e4b660
commit 8196422f9e
4 changed files with 25 additions and 2 deletions

17
poetry.lock generated
View file

@ -194,6 +194,17 @@ tzdata = {version = "*", markers = "sys_platform == \"win32\""}
argon2 = ["argon2-cffi (>=19.1.0)"]
bcrypt = ["bcrypt"]
[[package]]
name = "django-browser-reload"
version = "1.6.0"
description = "Automatically reload your browser in development."
category = "dev"
optional = false
python-versions = ">=3.7"
[package.dependencies]
Django = ">=3.2"
[[package]]
name = "django-cleanup"
version = "6.0.0"
@ -894,7 +905,7 @@ h11 = ">=0.9.0,<1"
[metadata]
lock-version = "1.1"
python-versions = ">=3.10.0, <4"
content-hash = "0dc2fab20f892efa2b0acbddd23ae1378d5c5ae24ece6357f11858c625cced68"
content-hash = "96bceed911ff3dca55ddfc85bf7d48e9056111b55aad6e05da5d3ebd2e9a60aa"
[metadata.files]
ansicon = [
@ -1108,6 +1119,10 @@ django = [
{file = "Django-4.1.2-py3-none-any.whl", hash = "sha256:26dc24f99c8956374a054bcbf58aab8dc0cad2e6ac82b0fe036b752c00eee793"},
{file = "Django-4.1.2.tar.gz", hash = "sha256:b8d843714810ab88d59344507d4447be8b2cf12a49031363b6eed9f1b9b2280f"},
]
django-browser-reload = [
{file = "django-browser-reload-1.6.0.tar.gz", hash = "sha256:9ca69c71796f53868bdc7421f120d147f7a64faa0d5d8c06970ba3f8061af63c"},
{file = "django_browser_reload-1.6.0-py3-none-any.whl", hash = "sha256:31b8b2d51e8faa5878f21e6b60b8f43e1123907c6e082e9e967962ba63958829"},
]
django-cleanup = [
{file = "django-cleanup-6.0.0.tar.gz", hash = "sha256:922e06ef8839c92bd3ab37a84db6058b8764f3fe44dbb4487bbca941d288280a"},
{file = "django_cleanup-6.0.0-py2.py3-none-any.whl", hash = "sha256:997feab3b1f7a2e84f71c29e83b1d664459ec0d4b1924977b1fa25b5babb8703"},

View file

@ -33,6 +33,7 @@ bpython = ">=0.22.1"
poetry-deps-scanner = ">=2.0.0"
invoke = ">=1.7.3"
hypothesis = ">=6.56.4"
django-browser-reload = ">=1.6.0"
[build-system]
requires = ["poetry-core>=1.0.0"]

View file

@ -55,7 +55,9 @@ EXTERNAL_APPS = [
"django_cleanup.apps.CleanupConfig", # should be last: https://pypi.org/project/django-cleanup/
]
if DEBUG_TOOLBAR:
EXTERNAL_APPS.append("debug_toolbar")
EXTERNAL_APPS.insert(-2, "debug_toolbar")
if DEBUG:
EXTERNAL_APPS.insert(-2, "django_browser_reload")
CUSTOM_APPS = [
"whitenoise.runserver_nostatic", # should be first
@ -78,6 +80,8 @@ MIDDLEWARE = [
]
if DEBUG_TOOLBAR:
MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware")
if DEBUG:
MIDDLEWARE.append("django_browser_reload.middleware.BrowserReloadMiddleware")
ROOT_URLCONF = "charasheet.urls"

View file

@ -32,3 +32,6 @@ urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if settings.DEBUG_TOOLBAR:
urlpatterns.insert(0, path("__debug__/", include("debug_toolbar.urls")))
if settings.DEBUG:
urlpatterns.insert(0, path("__reload__/", include("django_browser_reload.urls")))