5👍
✅
It should be something like:
from django.db.models import F, Max
RoundTable.objects
.annotate(diff=F('total_seats')-F('occupied_seats'))
.aggregate(Max('diff'))
1👍
Try this,
from django.db.models import Max, F, ExpressionWrapper, IntegerField
RoundTable.objects.annotate(diff=ExpressionWrapper(
F('total_seats') - F('occupied_seats'), output_field=IntegerField()
)).aggregate(max=Max('diff'))
👤JPG
- [Django]-Django Rest Framework Serializer Model Custom Method with parameters
- [Django]-How to get the database where a model instance was saved to in Django?
- [Django]-Django only submitting csrf token in forms?
Source:stackexchange.com