29👍
✅
No. Anything that goes through a built-in manager has to be a real field, since they only touch the database. In order to work with a property they’d have to turn every record in the table into a model, then filter through them in Python.
5👍
I have a similar scenario and want exactly the same feature. I solved it trivially with the following line:
...
return sum(lt.cost for lt in self.lineitem_set)
- [Django]-Django 1.9 deprecation warnings app_label
- [Django]-Slicing a list in Django template
- [Django]-Django: Querying read-only view with no primary key
- [Django]-Django project models.py versus app models.py
- [Django]-Django ModelChoiceField optgroup tag
- [Django]-Django stops working with RuntimeError: populate() isn't reentrant
Source:stackexchange.com