diff --git a/poetry.lock b/poetry.lock index fb60979..d13a9ee 100644 --- a/poetry.lock +++ b/poetry.lock @@ -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"}, diff --git a/pyproject.toml b/pyproject.toml index 64c4497..d185289 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] diff --git a/src/charasheet/settings.py b/src/charasheet/settings.py index 75bc31d..0e9caf7 100644 --- a/src/charasheet/settings.py +++ b/src/charasheet/settings.py @@ -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" diff --git a/src/charasheet/urls.py b/src/charasheet/urls.py index e0821ef..ed14bba 100644 --- a/src/charasheet/urls.py +++ b/src/charasheet/urls.py @@ -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")))