refactor: update static storage configuration for Django 5.2+ compatibility #93
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the eox-theming plugin to correctly inject its storage backends in compliance with Django 5.2 requirements. It ensures our custom logic for handling absolute URLs remains functional, preventing broken assets (such as logos) across the platform.
Context & Problem
In recent Django versions (5.2+), the
STATICFILES_STORAGEsetting has been deprecated in favor of theSTORAGESdictionary. Additionally, the internal implementation of Django’s base storage.url()method was changed from usingurljoin(which intelligently detected absolute URLs) to a simple string concatenation.Because of this change, when the platform requested a static asset that was already an absolute URL (e.g., a Bragi logo hosted on S3), the upgraded Django logic was prepending the
STATIC_URLprefix, resulting in broken paths like:https://your-platform.com/static/https%3A/s3.amazonaws.com/bragi-assets/logo.pngThis specifically broke the rendering of Bragi logos and other themed assets that rely on external absolute URLs.
You can see more information through:
Solution
We utilize our
AbsoluteUrlAssetsMixinwithin theeox-themingstorage classes. This mixin overrides the.url()method to:namestarts withhttp://orhttps://.nameimmediately as-is.To ensure this mixin is correctly applied in modern Django versions, this PR:
STATICFILES_STORAGEto theSTORAGES['staticfiles']dictionary.hasattrandsetdefault) to preventAttributeErrorduring tests where the settings object might be a dummy or partially initialized class.Technical Verification & Evidence
This change has been rigorously tested:
/static/prefix.LMS + Bragi (Ulmo) Before:
LMS + Bragi (Ulmo) After:
Changes
eox_theming/settings/common.pyto populatesettings.STORAGES['staticfiles']using a non-destructive approach.STORAGESattribute was missing from theSettingsClassdummy object.Impact
make test-python) without configuration errors.Checklist for Merge