本文整理汇总了Python中registration.users.UserModel.exists方法的典型用法代码示例。如果您正苦于以下问题:Python UserModel.exists方法的具体用法?Python UserModel.exists怎么用?Python UserModel.exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类registration.users.UserModel
的用法示例。
在下文中一共展示了UserModel.exists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clean_email
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import exists [as 别名]
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']
示例2: clean_email
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import exists [as 别名]
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']
示例3: clean_username
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import exists [as 别名]
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']
示例4: clean_username
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import exists [as 别名]
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']
示例5: validate_email
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import exists [as 别名]
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."))