I have two models in our django app
class Reg(models.Model):
transactions = ManyToMany
price = IntegerField
class Transaction(models.Model)
amount = IntegerField
Now I would like to make a lookup like:
Registration.objects.filter(reg__price==transaction__amount)
Previously we used the following approach:
- Registration has a property is_paid that computes wether a transaction with equal amount exists
- [r for r in Registration.objects.filter(...) if r.is_paid]
This is ofc very query-consuming and inefficient. I wonder whether there would be a better way to do this! Any hint is appreciated :)
IntegerField()andManyToMany('Transaction').amount?