[Python] Django join where values not null

Discussão em 'Python' iniciado por Stack, Agosto 25, 2025.

  1. Stack

    Stack Membro Participativo

    I have 3 Tabels in Django

    class Transactions(models.Model):
    public_key = models.ForeignKey(Keys, on_delete=models.CASCADE)
    txid = models.CharField(max_length=30)
    timestamp = models.DateTimeField()
    hash = models.CharField(max_length=64)
    block = models.IntegerField()
    amount = models.IntegerField()
    saldo = models.IntegerField()
    fee = models.IntegerField()
    fiat_CHF = models.FloatField(default=0)
    fiat_USD = models.FloatField(default=0)
    fiat_EUR = models.FloatField(default=0)
    position = models.IntegerField(default=0)

    class Price(models.Model):
    date = models.DateTimeField()
    price = models.FloatField()
    fiat = models.ForeignKey(Currencies, on_delete=models.DO_NOTHING)

    class PriceTextBackup(models.Model):
    date = models.CharField(max_length=20)
    price = models.FloatField()
    fiat = models.ForeignKey(Currencies, on_delete=models.DO_NOTHING)


    Now i want to 'join' transactions with price on the date, if it is null i want to check the text backup, if it is still null, i want it to be 0.

    Is that possible? and how?

    Continue reading...

Compartilhe esta Página