我有模型:
class Model_1(models.Model):
name = models.CharField(...
pos = models.IntegerField(...
class Model_2(models.Model):
...
m1 = models.ManyToManyField(Model_1,...
我在模板中打印这个:
{% for m2 in model2 %}
{% for m1 in m2.m1.all %}
{{ m1.name }}
{% endfor %}
{% endfor %}
但我想打印按“pos”字段排序的 m1.names。怎么做?