def clean_email(self): if self.instance.pk != None: existing_user = UserModel().objects.filter(username__iexact=self.cleaned_data['email']) existing = Rolnik.objects.get(pk=self.instance.pk) if existing_user.exists() and existing.user != existing_user[0]: raise forms.ValidationError(_("This email belongs to someone else.")) return self.cleaned_data['email'] existing = UserModel().objects.filter(username__iexact=self.cleaned_data['email']) if existing.exists(): raise forms.ValidationError(_("A user with that username already exists.")) else: return self.cleaned_data['email']
def clean_email(self): existing = UserModel().objects.filter(email__iexact=self.cleaned_data['email']) if existing.exists(): raise forms.ValidationError(_("A user with that email already exists.")) else: return self.cleaned_data['email']
def clean_username(self): """ Validate that the username is alphanumeric and is not already in use. """ existing = UserModel().objects.filter(username__iexact=self.cleaned_data['username']) if existing.exists(): raise forms.ValidationError(_("A user with that username already exists.")) else: return self.cleaned_data['username']
def clean_username(self): """ Validate that the username is alphanumeric and is not already in use. """ kwargs = {UserModel().USERNAME_FIELD: self.cleaned_data['username']} existing = UserModel().objects.filter(**kwargs) if existing.exists(): raise forms.ValidationError(_("A user with that username already exists.")) else: return self.cleaned_data['username']
def validate_email(value): existing = UserModel().objects.filter(email__iexact=value) if not existing.exists(): raise forms.ValidationError( _("A user with that email doesn't exists."))
def validate_email(value): existing = UserModel().objects.filter(email__iexact=value) if not existing.exists(): raise forms.ValidationError(_("A user with that email doesn't exists."))