python - Django using aggregate MAX -


i have following...

r = region.objects.get_location_name(user.location) 

which returns:

[<region: great britain>, <region: europe>] 

next want return object max highest parent.

i have tried this:

r = region.objects.get_location_name(user.location).aggregate(max('level')) 

but not return object returns...

{'level__max': 1} 

why?

you're looking order_by: sort queryset descending 'level' , first item doing queryset[0].

i think code should like

r = region.objects.get_location_name(user.location).order_by('-level')[0] 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -