def validate_users(form, field=u'users'):
 local_site = form.cleaned_data[u'local_site']
 users = form.cleaned_data.get(field, [])
 if local_site:
  for user in users:
   if (not user.local_site.filter(pk=local_site.pk).exists()):
    raise ValidationError([(_(u'The user %s is not a member of this site.') % user.username)])
 return users

def validate_users ( form , field = u'users' ) : local_site = form . cleaned_data [ u'local_site' ] users = form . cleaned_data . get ( field , [ ] ) if local_site : for user in users : if ( not user . local_site . filter ( pk = local_site . pk ) . exists ( ) ) : raise ValidationError ( [ ( _ ( u'The user %s is not a member of this site.' ) % user . username ) ] ) return users
validates that the users all have valid .