-1

i'm, trying to do something like this :

c = if x > y return x else return y

inner annotate function

class factura (models.MODEL):
    price = Model.integerField(max_length=50, null=False)
    articles = Models.charField(Max_length=50, default=0, null=False)
    iva = Models.integerField(max_length=50)
    discount = Model.integerField((max_length=50)

factura.objects.annotate(
    total = if total_articles > price return iva else return 

thnks

1 Answers1

0

You can define a model method to compare the value:


class factura (models.Model):
    ...

    @property
    def check_article(self):
        if int(self.articles) > int(self.price): return 'iva' 
        else: return 

You can then do:

    qs=factura.objects.all()
    for instance in qs:
        print(instance.check_article)
Mugoma
  • 294
  • 2
  • 8