Replies: 2 comments 1 reply
-
Would the following code work in your case? from django.contrib.staticfiles.storage import staticfiles_storage
staticfiles_storage.open('icons/plus.svg') |
Beta Was this translation helpful? Give feedback.
1 reply
-
I've rewritten icons loading to be compatible with such static file storage in #13619. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an application that uses Weblate to manage translations. I use weblate/weblate Docker image, with my own customizations built as a separate Python package extending this image and built on top of it. The problem is that in the Weblate HTML templates there is an icon template tag that is supposed to load SVG icons from a STATIC_ROOT or a CACHE_DIR location - but my application runs in a serverless setup and as such offloads all of the static resources to a S3 bucket. For most of the resources it works fine, but due to that template tag logic the icons are not loaded and I get these error messages -
I wrote my custom template tag, which I placed in my custom module weblate_customization/templatetags/icon.py, but it does not override weblate default icon loading logic, and I cannot access the default templates in my code, unless I monkey-patch. The code for the default icon template tag exists within weblate.utils app, which is included within the base image and loads all of the utility functionality required by the application to function, so I can't just throw it out. Is there a way to make Django load my custom version of this template tag, instead of the one provided by weblate?
The logic of the default template tag goes like this:
weblate/weblate/utils/templatetags/icon.py
Whereas the logic I am trying to implement is the following:
weblate_customization/templatetags/icon.py
How do I make Django to use the simple tag I specify instead of the default one? I cannot rename it to something like "new_icon" and overwrite the templates since the templates come from the base docker image, as well as the weblate.utils module itself, where the template tags are defined and registered.
Beta Was this translation helpful? Give feedback.
All reactions