Skip to content

Instantly share code, notes, and snippets.

@tijs
Created December 16, 2013 16:05
Show Gist options
  • Save tijs/7989500 to your computer and use it in GitHub Desktop.
Save tijs/7989500 to your computer and use it in GitHub Desktop.
Prevent iOS (and maybe other mobile OSs as well) from auto capitalizing your username field, which in a standard Django auth setup would prevent these people from signing up with their uncapitalized username (or email for custom backends) when they try to login later.
class LoginForm(AuthenticationForm):
""" Subclass the default AuthenticationForm and overwrite the username widget attributes """
def __init__(self, *args, **kwargs):
super(LoginForm, self).__init__(*args, **kwargs)
self.fields['username'].widget.attrs.update({'autocapitalize':'off', 'autocorrect': 'off'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment