Skip to content

Instantly share code, notes, and snippets.

@tuxcanfly
Created March 26, 2013 09:28
Show Gist options
  • Save tuxcanfly/5244136 to your computer and use it in GitHub Desktop.
Save tuxcanfly/5244136 to your computer and use it in GitHub Desktop.
Django forms won't clean a second time.
>>> from django.contrib.auth.forms import UserCreationForm
>>> form = UserCreationForm({'username': 'admin123', 'password1': 's3cr3t', 'password2': 's3cr3t'})
>>> form.is_valid()
True
>>> form.data['username'] = ''
>>> form.is_valid()
True
>>> form._errors = None
>>> form.is_valid()
False
>>> form.errors
{'username': [u'This field is required.']}
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment