When I try to self check if p_username
key is available in cleaned_data
, using following code:
def clean(self):
username = self.cleaned_data['p_username']
if User.objects.filter(username=username).exists():
raise forms.ValidationError('Username already exists.')
return username
This code is returning me.
def clean(self):
^
IndentationError: unindent does not match any outer indentation level