To easily version my css file using a simple template variable, I update the version in my settings and it automatically applies to all files. Here's how I accomplish this:
Template Filter
@register.filter
def settings_value(name):
return getattr(settings, name, "")
Template
{% with "APP_VERSION"|settings_value as v %}
<link rel="stylesheet" href="css/style.css?v={{ V }}"/>
{%endwith%}
This method works perfectly fine. However, my current css path is set like this:
<link rel="stylesheet" href="{% static 'css/style.css?v=' %}"/>
I am looking for a way to apply the version number in this format.
What I've Tried
<link rel="stylesheet" href="{% static 'css/style.css?v=' %}{{ v }}"/>
Unfortunately, this approach does not work. Any suggestions? Thank you.