Mise en cache des CSS de styles
This commit is contained in:
parent
bf4bac340d
commit
9a0b62aa16
@ -1,5 +1,6 @@
|
|||||||
from django import template
|
from django import template
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
from django.core.cache import cache
|
||||||
|
|
||||||
from agenda_culturel.models import Category
|
from agenda_culturel.models import Category
|
||||||
import colorsys
|
import colorsys
|
||||||
@ -67,6 +68,8 @@ def background_color_adjust_color(color, alpha=1):
|
|||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def css_categories():
|
def css_categories():
|
||||||
|
result = cache.get('css_categories')
|
||||||
|
if not result: #
|
||||||
result = '<style type="text/css">'
|
result = '<style type="text/css">'
|
||||||
|
|
||||||
cats = [
|
cats = [
|
||||||
@ -120,6 +123,7 @@ def css_categories():
|
|||||||
result += "}"
|
result += "}"
|
||||||
|
|
||||||
result += "</style>"
|
result += "</style>"
|
||||||
|
cache.set('css_categories', result, 3600) # 1 hour
|
||||||
return mark_safe(result)
|
return mark_safe(result)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user