def __init__(self,
                 public_key=None,
                 private_key=None,
                 use_ssl=None,
                 attrs=None,
                 *args,
                 **kwargs):
        """
        ReCaptchaField can accepts attributes which is a dictionary of
        attributes to be passed to the ReCaptcha widget class. The widget will
        loop over any options added and create the RecaptchaOptions
        JavaScript variables as specified in
        https://code.google.com/apis/recaptcha/docs/customization.html
        """
        if attrs is None:
            attrs = {}
        public_key = public_key if public_key else \
            settings.RECAPTCHA_PUBLIC_KEY
        self.private_key = private_key if private_key else \
            settings.RECAPTCHA_PRIVATE_KEY
        self.use_ssl = use_ssl if use_ssl is not None else getattr(
            settings, 'RECAPTCHA_USE_SSL', True)

        self.widget = ReCaptcha(public_key=public_key,
                                use_ssl=self.use_ssl,
                                attrs=attrs)
        self.required = True
        super(ReCaptchaField, self).__init__(*args, **kwargs)
示例#2
0
 def __init__(self, attrs={}, *args, **kwargs):
     self.widget = ReCaptcha(attrs=attrs)
     self.required = True
     super(ReCaptchaField, self).__init__(*args, **kwargs)