diff --git a/app/app/settings.py b/app/app/settings.py index c9773630..f47b003f 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -97,6 +97,7 @@ TEMPLATES = [ ], 'libraries': { 'analytics': 'server.templatetags.analytics', + 'utils_templating': 'authentification.templatetags.utils_templating', }, }, }, diff --git a/app/authentification/templatetags/utils_templating.py b/app/authentification/templatetags/utils_templating.py new file mode 100644 index 00000000..bd747cba --- /dev/null +++ b/app/authentification/templatetags/utils_templating.py @@ -0,0 +1,10 @@ +from django import template + +register = template.Library() + +@register.filter(name='addcss') +def addcss(value, arg): + css_classes = value.field.widget.attrs.get('class', '').split(' ') + if css_classes and arg not in css_classes: + css_classes = '%s %s' % (css_classes, arg) + return value.as_widget(attrs={'class': css_classes})