'If request is passed in, the form will validate that cookies are
enabled. Note that the request (a HttpRequest object) must have set a
cookie with the key TEST_COOKIE_NAME and value TEST_COOKIE_VALUE before
running this validation.'

def __init__(self, request=None, *args, **kwargs):

    self.request = request
    self.user_cache = None
    super(AuthenticationForm, self).__init__(*args, **kwargs)
    UserModel = get_user_model()
    self.username_field = UserModel._meta.get_field(UserModel.USERNAME_FIELD)
    if (not self.fields[u'username'].label):
        self.fields[u'username'].label = capfirst(self.username_field.verbose_name)
