from collections import defaultdict
users = defaultdict(list)
for result in UserExtendedProfile.objects.values('company', 'user').order_by(
    'company', 'user'):
    users[result['company']].append(result['user'])
Group by Foreign Key and show related items - Django