1)
Open Django shell
#python manage.py shell
2)
>>>
>>>
>>> from django.db.models import Count
>>> from bla.core.models import Building
>>>
>>> Building.objects.filter(agent=454200).aggregate(count=Count('user'))
{'count': 29}
>>>
>>>
>>> Building.objects.filter(agent=454200).aggregate(count=Count('user', distinct=True))
{'count': 7}
>>>
>>>
>>>
>>>
>>> user_tot = 0
>>> for b in Building.objects.filter(agent=454200).all():
... if b.user:
... user_tot += 1
...
>>>
>>>
>>> user_tot
29
>>>
>>>
>>>
Open Django shell
#python manage.py shell
2)
>>>
>>>
>>> from django.db.models import Count
>>> from bla.core.models import Building
>>>
>>> Building.objects.filter(agent=454200).aggregate(count=Count('user'))
{'count': 29}
>>>
>>>
>>> Building.objects.filter(agent=454200).aggregate(count=Count('user', distinct=True))
{'count': 7}
>>>
>>>
>>>
>>>
>>> user_tot = 0
>>> for b in Building.objects.filter(agent=454200).all():
... if b.user:
... user_tot += 1
...
>>>
>>>
>>> user_tot
29
>>>
>>>
>>>
sir,
ReplyDeleteagent=454200 what base u select value i means how can identity this value
This comment has been removed by the author.
ReplyDelete