This is an automated email from the ASF dual-hosted git repository. skrawcz pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/hamilton.git
commit 6c9af8048a3f1275fb717bb298a10865bb465a70 Author: Stefan Krawczyk <[email protected]> AuthorDate: Sat Feb 28 13:19:13 2026 -0800 Use pathlib consistently for build directory paths in Django settings and urls --- ui/backend/server/server/settings.py | 16 +++++++--------- ui/backend/server/server/urls.py | 12 ++++++------ ui/{migrate_postgres.sh => upgrade_postgres.sh} | 0 ...ate_postgres_simple.sh => upgrade_postgres_simple.sh} | 0 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/ui/backend/server/server/settings.py b/ui/backend/server/server/settings.py index 5d3066dc..ce213f48 100644 --- a/ui/backend/server/server/settings.py +++ b/ui/backend/server/server/settings.py @@ -124,9 +124,7 @@ ROOT_URLCONF = "server.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": ( - [os.path.join(BASE_DIR, "build")] if HAMILTON_ENV == "mini" else [] - ), # TODO -- unify + "DIRS": ([BASE_DIR / "build"] if HAMILTON_ENV == "mini" else []), # TODO -- unify "APP_DIRS": True, "OPTIONS": { "context_processors": [ @@ -146,17 +144,17 @@ STATIC_URL = "static/" # TODO -- unify this/fix with the mini settings if HAMILTON_ENV == "mini": - STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") + STATIC_ROOT = BASE_DIR / "staticfiles" STATIC_URL = "/static/" # Support both Vite (assets/) and CRA (static/) build outputs staticfiles_dirs = [] - if (BASE_DIR / "build/assets/").exists(): - staticfiles_dirs.append(str(BASE_DIR / "build/assets/")) - if (BASE_DIR / "build/static/").exists(): - staticfiles_dirs.append(str(BASE_DIR / "build/static/")) + if (BASE_DIR / "build" / "assets").exists(): + staticfiles_dirs.append(BASE_DIR / "build/assets") + if (BASE_DIR / "build/static").exists(): + staticfiles_dirs.append(BASE_DIR / "build/static") STATICFILES_DIRS = staticfiles_dirs MEDIA_URL = "/media/" - MEDIA_ROOT = str(BASE_DIR / "build/") + MEDIA_ROOT = (BASE_DIR / "build").as_posix() # Database # https://docs.djangoproject.com/en/4.1/ref/settings/#databases diff --git a/ui/backend/server/server/urls.py b/ui/backend/server/server/urls.py index cf34ab03..516d9a2b 100644 --- a/ui/backend/server/server/urls.py +++ b/ui/backend/server/server/urls.py @@ -49,7 +49,7 @@ if settings.HAMILTON_ENV == "mini": ] # Serve root-level assets from build/ directory - build_dir = settings.BASE_DIR / "build/" + build_dir = settings.BASE_DIR / "build" root_assets = [ "manifest.json", "robots.txt", @@ -61,25 +61,25 @@ if settings.HAMILTON_ENV == "mini": for asset in root_assets: if (build_dir / asset).exists(): urlpatterns.append( - re_path(rf"^{asset}$", serve, {"document_root": str(build_dir), "path": asset}) + re_path(rf"^{asset}$", serve, {"document_root": build_dir, "path": asset}) ) # Serve static assets from build/assets/ (Vite) or build/static/ (CRA) # This MUST come before the catch-all route - if (settings.BASE_DIR / "build/assets/").exists(): + if (settings.BASE_DIR / "build" / "assets").exists(): urlpatterns.append( re_path( r"^assets/(?P<path>.*)$", serve, - {"document_root": str(settings.BASE_DIR / "build/assets/")}, + {"document_root": settings.BASE_DIR / "build" / "assets"}, ) ) - if (settings.BASE_DIR / "build/static/").exists(): + if (settings.BASE_DIR / "build" / "static").exists(): urlpatterns.append( re_path( r"^static/(?P<path>.*)$", serve, - {"document_root": str(settings.BASE_DIR / "build/static/")}, + {"document_root": settings.BASE_DIR / "build" / "static"}, ) ) diff --git a/ui/migrate_postgres.sh b/ui/upgrade_postgres.sh similarity index 100% rename from ui/migrate_postgres.sh rename to ui/upgrade_postgres.sh diff --git a/ui/migrate_postgres_simple.sh b/ui/upgrade_postgres_simple.sh similarity index 100% rename from ui/migrate_postgres_simple.sh rename to ui/upgrade_postgres_simple.sh
