To use this - add add_attr.py
to you your Django project in the templatetags
directory.
Structure would look something like this:
- Project Dir
- App Dir
- templatetags
add_attr.py
- templatetags
- App Dir
In the view where you want to add an attribute to something - you would load it at the top of the file with
{% load add_attr %}
Useage within the view template:
{% add_attr form.username class='form-control' %}
This adds a class to the form.username element of 'form-control'