[Answered ]-How do I create a Django model field that evaluates based on other fields?

2👍

Your model classes are full Python classes, so you can add attributes, methods, and properties to them:

class ItemCombo(models.Model):
    item1         = models.ForeignKey(Item)
    item2         = models.ForeignKey(Item)

    @property
    def combocategory(self):
        return .. # some mumbo-jumbo of item1 and item2

0👍

The issue is that you can only do queries on fields that are stored in the database. Now you should look at aggregation for a way to evaluate your ItemCombo just in time and do filtering on it.

👤Nathan

Leave a comment