title: Django Template: Comparing Dictionary Length in IF Statement
body: <p>I am trying to compare the length of a dictionary inside a django template</p>
  
  <p>For example, I would like to know the correct syntax to do the following:</p>
  
  <pre><code>    {% if error_messages %}
          &lt;div class="error"&gt;
              {% if length(error_messages) &gt; 1 %}
                  Please fix the following errors:
                  &lt;div class="erroritem"&gt;
                      {% for key, value in error_messages.items %}
                          &lt;br&gt;{{ value }}
                      {% endfor %}
                  &lt;/div&gt;
  
              {% else %}
                      {% for key, value in error_messages.items %}
                          {{ value }}
                      {% endfor %}
              {% endif %}
          &lt;/div&gt;
      {% endif %}
  </code></pre>