📌  相关文章
📜  检查数据库 django 中是否存在用户名 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:30.728000             🧑  作者: Mango

代码示例1
class FormClass:
    username = ...
    def clean(self):
        super(FormClass, self).clean()
        username = self.cleaned_data['username']
        if User.objects.exclude(pk=self.instance.pk).filter(username=username).exists():
            raise forms.ValidationError(f'Username "{username}" is already in use.')
        return username