我有模特:
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。怎么做?