Answers for "check if username exists in database django"

0

check if username exists in database django

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
Posted by: Guest on June-07-2021

Code answers related to "check if username exists in database django"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language