[Answer]-Django filter and annotate

1👍

You can order the cities with maximum number of Architects like this –

City.objects.filter(user__Iam='Architect').annotate(num_user=Count('user')).orde‌​r_by('-num_user')

This first filters cities that have architects, then counts the architects and then order by them in descending order.

Leave a comment