Override existing custom Django App template tags

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 -

weblate-1   | gunicorn stderr | [2025-01-21 12:41:08,913: WARNING/1540] Could not load icon: FileNotFoundError: [Errno 2] No such file or directory: '/app/cache/static/icons/weblate.svg'
weblate-1   | gunicorn stderr | [2025-01-21 12:41:08,918: WARNING/1540] Could not load icon: FileNotFoundError: [Errno 2] No such file or directory: '/app/cache/static/icons/wrench.svg'
weblate-1   | gunicorn stderr | [2025-01-21 12:41:08,919: WARNING/1540] Could not load icon: FileNotFoundError: [Errno 2] No such file or directory: '/app/cache/static/icons/plus.svg'
weblate-1   | gunicorn stderr | [2025-01-21 12:41:08,923: WARNING/1540] Could not load icon: FileNotFoundError: [Errno 2] No such file or directory: '/app/cache/static/icons/dots.svg'

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?

Вернуться на верх