Получение целочисленного значения из models.PositiveIntegerField() (Django)

<
class SomeClass(models.Model):
    par = models.PositiveIntegerField() #Making field thar I will compile below
class SomeAnotherClass(models.Model):
    q = models.PositiveIntegerField()
    w = models.PositiveIntegerField()
    e = models.PositiveIntegerField()
    r = models.PositiveIntegerField()
    t = models.PositiveIntegerField()# Some things i need
    all = [q,w,e,r,t]
    counter = 0
    if q!=0:
        counter+=1
    if w!=0:
        counter+=1
    if e!=0:
        counter+=1
    if r!=0:
        counter+=1
    if t!=0:
        counter+=1 #IDK how to make it more elegant..(helping with that is appreciated)
    if SomeClass.par*counter<=sum(all_rounds[:counter]):# And here are 2 errors, out of <TypeError: unsupported operand type(s) for *: 'DeferredAttribute' and 'int'> and <TypeError: unsupported operand type(s) for +: 'int' and 'IntegerField'>
        to_par=f'+{sum(all_rounds[:counter])-SomeClass.par*counter}'#Same here
    if SomeClass.par*counter>sum(all_rounds[:counter]):#Here
        to_par=f'-{SomeClass.par*counter-sum(all_rounds[:counter])}'#And here


<
  File "C:\...", line 47, in SomeAnotherClass
    if SomeClass.par*counter<=sum(all[:counter]):
       ~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for *: 'DeferredAttribute' and 'int'

<
  File "C:\...", line 47, in SomeAnotherClass
    if counter<=sum(all[:counter]):
                ^^^^^^^^^^^^^^^^^^
TypeError: unsupported operand type(s) for +: 'int' and 'IntegerField'

Я пробовал get(),value(),int(),int(str()), какие-то странные функции из web.

Вернуться на верх