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.
- [Answered ]-Display superscript in Django Admin
- [Answered ]-How to get changes realtime with jquery in Django
- [Answered ]-Django – executing queries in save method
- [Answered ]-.serialize() returns empty dict. What do i do wrong?
- [Answered ]-How can i disable variable with locals()?
Source:stackexchange.com