name = models.CharField(max_length=80, verbose_name='Name', unique=True)
class Document(models.Model):
title = models.CharField(max_length=100)
school = models.ForeignKey(School, null=True, blank=True)
status = models.CharField(max_length=1, choices=STATUS_VALUES)
sorted_schools_by_docs_count_and_status = School.objects.annotate(num_docs=Count('document', status='1')).order_by('-num_docs'))
Ругнется на status=1
Обсуждают сегодня