[FIX] Don't use static for the custom-styles.css file

Since this CSS file is not part of the regular static collection, but gets created on demand, `ManifestStaticFilesStorage` will not work here. So we have to call the file directly, instead via `static` or we get:

ValueError: Missing staticfiles manifest entry for 'allianceauth/custom-styles.css'
This commit is contained in:
Peter Pfeufer 2025-07-08 22:11:20 +02:00
parent 34b94ae685
commit 3f17da684e
No known key found for this signature in database

View File

@ -8,7 +8,6 @@ from allianceauth.custom_css.models import CustomCSS
# Django # Django
from django.conf import settings from django.conf import settings
from django.template.defaulttags import register from django.template.defaulttags import register
from django.templatetags.static import static
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from pathlib import Path from pathlib import Path
@ -20,7 +19,7 @@ def custom_css_static(path: str) -> str:
Versioned static URL Versioned static URL
This is to make sure to break the browser cache on CSS updates. This is to make sure to break the browser cache on CSS updates.
Example: /static/allianceauth/custom-styles.css?v=1234567890 Example: /static/allianceauth/custom-styles.css?v=1752004819.555084
:param path: :param path:
:type path: :type path:
@ -42,7 +41,6 @@ def custom_css_static(path: str) -> str:
custom_css_version = ( custom_css_version = (
str(custom_css_changed).replace(" ", "").replace(":", "").replace("-", "") str(custom_css_changed).replace(" ", "").replace(":", "").replace("-", "")
) # remove spaces, colons, and dashes ) # remove spaces, colons, and dashes
static_url = static(path) versioned_url = f"{settings.STATIC_URL}{path}?v={custom_css_version}"
versioned_url = static_url + "?v=" + custom_css_version
return mark_safe(f'<link rel="stylesheet" href="{versioned_url}">') return mark_safe(f'<link rel="stylesheet" href="{versioned_url}">')