title: How to set order_by only on ManytoManyfield in detailview (Django)?
body: <p>I have 2 models <code>Class</code> and <code>Student</code>. One field within the <code>Class</code> mdel has a <code>ManytoManyField</code> relationship with <code>Student</code>. I want to order the manytomanyfield with <code>first_name</code> in the template. How can I do it?</p>
  <p>models.py</p>
  <pre><code>class Student(models.Model):
      user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, primary_key=True)
      first_name = models.CharField(max_length=100)
  
  
  class Class(models.Model):
      student = models.ManyToManyField(Student)
      subject = models.CharField(max_length=150, unique=True)
      # many other fields
  </code></pre>
  <p>views.py</p>
  <pre><code>class Class_detailView(LoginRequiredMixin, DetailView):
      login_url = '/'
      model = Class
      template_name = &quot;attendance/content/teacher/class_detail.html
  </code></pre>
  <p>template</p>
  <pre><code>&lt;div class=&quot;row ml-auto mr-auto&quot;&gt;
    &lt;h6&gt;{{ object.subject }}&lt;/h6&gt;
    {% for student in object.student.all %}
      &lt;h6 id=&quot;class-detail-text&quot; class=&quot;mt-2&quot;&gt;
        {{student.first_name}} &lt;-- want to order here
      &lt;/h6&gt;
    {% endfor %}
  &lt;/div&gt;
  </code></pre>
  <p>right now the names render like this:</p>
  <pre><code>Freaky  Albon  Bucky
  </code></pre>
  <p>I want it to order like this:</p>
  <pre><code>Albon   Bucky  Freaky
  </code></pre>