Add class to Django label_tag() output
Technique 1 I take issue with another answer’s assertion that a filter would be “less elegant.” As you can see, it’s very elegant indeed. @register.filter(is_safe=True) def label_with_classes(value, arg): return value.label_tag(attrs={‘class’: arg}) Using this in a template is just as elegant: {{ form.my_field|label_with_classes:”class1 class2″}} Technique 2 Alternatively, one of the more interesting technique I’ve found is: … Read more