Python django.conf.settings 模块,RECAPTCHA_PRIVATE_KEY 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用django.conf.settings.RECAPTCHA_PRIVATE_KEY

项目:fieldsight-kobocat    作者:awemulya    | 项目源码 | 文件源码
def clean(self):
        cleaned_data = super(UserProfileFormRegister, self).clean()

        # don't check captcha if it's disabled
        if not self.REGISTRATION_REQUIRE_CAPTCHA:
            if 'recaptcha_response_field' in self._errors:
                del self._errors['recaptcha_response_field']
            return cleaned_data

        response = captcha.submit(
            cleaned_data.get('recaptcha_challenge_field'),
            cleaned_data.get('recaptcha_response_field'),
            settings.RECAPTCHA_PRIVATE_KEY,
            None)

        if not response.is_valid:
            raise forms.ValidationError(_(u"The Captcha is invalid. "
                                          u"Please, try again."))
        return cleaned_data

    # This code use to be in clean_username. Now clean_username is just
    # a convenience proxy to this method. This method is here to allow
    # the UserProfileSerializer to validate the username without reinventing
    # the wheel while still avoiding the need to instancate the form. A even
    # cleaner way would be a shared custom validator.
项目:FormShare    作者:qlands    | 项目源码 | 文件源码
def clean(self):
        cleaned_data = super(UserProfileFormRegister, self).clean()

        # don't check captcha if it's disabled
        if not self.REGISTRATION_REQUIRE_CAPTCHA:
            if 'recaptcha_response_field' in self._errors:
                del self._errors['recaptcha_response_field']
            return cleaned_data

        response = captcha.submit(
            cleaned_data.get('recaptcha_challenge_field'),
            cleaned_data.get('recaptcha_response_field'),
            settings.RECAPTCHA_PRIVATE_KEY,
            None)

        if not response.is_valid:
            raise forms.ValidationError(_(u"The Captcha is invalid. "
                                          u"Please, try again."))
        return cleaned_data