title: How to order by fields in Django
body: <p>For my case it will be very important to get the order right. I need to sort my MonthlySpending objects by its index. I have tried the dictsort from django template but does not work.</p>
  
  <p>I have also included the ordering in my models, however, the ordering is not shown in the HTML but it does show in the admin.</p>
  
  <p>Are there anyways i can sort my objects by its index?</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>{% for month in object.monthlyspending_set.all|dictsort:"index" %}
      &lt;tr class="yeardata "&gt;
          &lt;td&gt;{{ month.name }}&lt;/td&gt;
          &lt;td&gt;$ {{ month.monthly_income }}&lt;/td&gt;
          &lt;td&gt;$ &lt;a href="{% url 'finances:detail' month.slug %}"&gt;{{ month.target_savings }}&lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;$ {{ month.actual_savings }}&lt;/td&gt;
          &lt;td&gt;{{ month.percentage_met }} %&lt;/td&gt;
      &lt;/tr&gt;
    {% endfor %}
  </code></pre>
  
  <p><strong>Models.py</strong></p>
  
  <pre><code>class MonthlySpending(models.Model):
      name = models.CharField(max_length=100)
      annualspending = models.ForeignKey(AnnualSpending, on_delete=models.CASCADE)
      index = models.IntegerField()
      slug = models.SlugField()
      objects = models.Manager
  
      class Meta:
          ordering = ['index']
  </code></pre>