title: How To Provide A Class To Fields In A Django Template?
body: <p>I was working a project on mine, in which I needed to provide a class to a field in form which is a input box, but don't know how to do so.</p>
  
  <p>My Template:</p>
  
  <pre><code>{% extends 'diary/base.html' %}
  {% block title %}Register{% endblock title %}
  {% block content %}
  
  {% load staticfiles %}
  &lt;link rel= "stylesheet" type= "text/css" href = "{% static 'users/register.css' %}"&gt;
  
      &lt;div id="login-box"&gt;
          &lt;div class="left-box"&gt;
                  &lt;h1&gt;Register&lt;/h1&gt;
                  &lt;form action="{% url 'register' %}" method="post"&gt;
                      {% csrf_token %}
                      {% for non_field_error in form.non_field_errors %}
                          &lt;p&gt;{{ non_field_error }}&lt;/p&gt;
                      {% endfor %}
                      {% for field in form %}
                                  {{ field }}
                          {% for error in field.errors %}
                              &lt;p&gt;{{ error }}&lt;/p&gt;
                          {% endfor %}
                      {% endfor %}
                      &lt;input type="submit" value="SIGN UP" name="signup-button" class="signup-btn"&gt;
                  &lt;/form&gt;
          &lt;/div&gt;
          &lt;div class="right-box"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  {% endblock content %}
  </code></pre>
  
  <p>In this specific part:</p>
  
  <pre><code>{% for field in form %}
                  {{ field }}
          {% for error in field.errors %}
  </code></pre>
  
  <p>I want to provide a class to {{ field }}. </p>
  
  <p>I tried this: </p>
  
  <pre><code>{{ field(class="txtb") }}
  </code></pre>
  
  <p>This is how I use to provide a class in Flask, but in Django this didn't worked.</p>
  
  <p>Any Help Would Be Appreciated!</p>