Answer the question
In order to leave comments, you need to log in
How to sort in DB by number of objects in ListField in Django Rest Framework + Mongoengine?
There is the following model:
class Departments(Document):
_id = fields.ObjectIdField()
name = fields.StringField(blank=True, null=True)
department_id = fields.StringField(blank=True, null=True) # Added
list_of_users = fields.ListField(blank=True, null=True)
list_of_workstations = fields.ListField(blank=True, null=True)
departments = DepartmentStats.objects.order_by(len(list_of_users)).dsc
departments = DepartmentStats.objects.order_by(len(list_of_users)/len(list_of_workstations)).dsc
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question