Comment contrôlez-vous la version de vos fichiers statiques dans Django? Je wrote custom templatetag qui ajoute la date de modification en tant que paramètre GET de l'URL du fichier, mais j'aimerais savoir - si je le fais.Django fichiers statiques versions
Code Tag:
import os
from django import template
from django.conf import settings
register = template.Library()
@register.simple_tag
def sstatic(path):
'''
Returns absolute URL to static file with versioning.
'''
full_path = os.path.join(settings.STATIC_ROOT, path)
try:
# Get file modification time.
mtime = os.path.getmtime(full_path)
return '%s%s?%s' % (settings.STATIC_URL, path, mtime)
except OSError:
# Returns normal url if this file was not found in filesystem.
return '%s%s' % (settings.STATIC_URL, path)
Cela va retourner un chemin, mais comment modifier les noms de fichiers réels afin qu'ils correspondent à ce chemin? – silent1mezzo