值比较查询Django

下午好...我需要进行比较查询...我认为该代码段已实现,但返回错误...有人可以帮助我..

楷模

class Room (models.Model):
    block = models.ForeignKey (Block, on_delete = models.PROTECT)
    room = models.CharField ('Room:', unique = True, max_length = 50)
    capmax = models.IntegerField ('Maximum Cap:')
    available = models.BooleanField ('Available', default = True)
    busy = models.BooleanField ('Busy', default = False)
    internet = models.BooleanField ('Internet', default = False)
    projector = models.BooleanField ('Projector', default = True)
    computer = models.BooleanField ('Computer', default = False)
class  Estclass (models.Model):
    estclass = models.CharField ('Class', max_length = 20)
    course = models.CharField ('Course', null = False, max_length = 50)
    period = models.CharField ('Period', null = False, max_length = 50)
    discipline = models.CharField ('Discipline', max_length = 50)
    estudents = models.IntegerField ('Qty')
    professor = models.CharField ('Professor', max_length = 50)
    allocated = models.BooleanField ('Allocated', default = False)
    internet = models.BooleanField ('Internet', default = False)
    projector = models.BooleanField ('Projector', default = False)
    computer = models.BooleanField ('Computer', default = False)

class Allocate (models.Model):
    date = models.DateField ('Date', auto_now = True, blank = True)
    days = [
        ('Monday', 'Monday'),
        ('Tuesday', 'Tuesday'),
        ('Wednesday', 'Wednesday'),
        ('Thursday', 'Thursday'),
        ('Friday', 'Friday'),
        ('Saturday', 'Saturday'),
    ]
    day = models.CharField ('Day', max_length = 11, choices = days,
    default = 'Confirming')
    time = models.ForeignKey (Time, on_delete = models.CASCADE)
    estclass = models.ForeignKey (Class, on_delete = models.SET ())
    room = models.ForeignKey (Room, on_delete = models.SET ())

        .....
        room = Allocate.objects.select_related ('room'). values (room = room.capmax)
        capmax = int (room)
        estclass = Allocate.objects.select_related ('estclass'). values (estclass = estclass.estudents)
        capmax = int (estclass)

        if estclass > room:
            messages.info (request, 'Number of students greater than capacity')
            return redirect ('allocate: listalocate')
        .....   

错误返回...

/ listsalocate /处的TypeError QuerySet.annotate()接收到非表达式:40。