def METHOD_NAME(self):
    ref = self.cleaned_data.get("ref")
    try:
        user_id = int(ref)
    except ValueError:
        raise forms.ValidationError("ref不正确")
    if User.objects.filter(id=user_id).exists():
        return ref
    else:
        raise forms.ValidationError("ref不正确")