I see this in the UserCreationForm:
def clean_username(self):
# Since User.username is unique, this check is redundant,
# but it sets a nicer error message than the ORM. See #13147.
username = self.cleaned_data["username"]
try:
User._default_manager.get(username=username)
except User.DoesNotExist:
return username
raise forms.ValidationError(self.error_messages['duplicate_username'])
This method can be used in this way:
def register_me(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
uname = form.clean_username
See the last line above. The method is without the ()... Why???
uname?