Make the collectstatic hack slightly better

pull/184/head
Andrew Godwin 2022-12-16 19:51:19 -07:00
rodzic 770f6728f6
commit 4a28e1708e
2 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -1,3 +1,4 @@
import sys
from urllib.parse import urljoin
from django.conf import settings
@ -41,7 +42,15 @@ class StaticAbsoluteUrl(RelativeAbsoluteUrl):
"""
def __init__(self, path: str):
static_url = staticfiles_storage.url(path)
try:
static_url = staticfiles_storage.url(path)
except ValueError:
# Suppress static issues during the first collectstatic
# Yes, I know it's a big hack! Pull requests welcome :)
if "collectstatic" in sys.argv:
super().__init__("https://example.com/")
return
raise
if "://" in static_url:
super().__init__(static_url)
else:

Wyświetl plik

@ -32,7 +32,7 @@ COPY . /takahe
WORKDIR /takahe
RUN TAKAHE_DATABASE_SERVER="postgres://x@example.com/x" TAKAHE_DEBUG=true python3 manage.py collectstatic --noinput
RUN TAKAHE_DATABASE_SERVER="postgres://x@example.com/x" python3 manage.py collectstatic --noinput
EXPOSE 8000