當前位置: 首頁>>代碼示例>>Python>>正文


Python fields.CaptchaField方法代碼示例

本文整理匯總了Python中captcha.fields.CaptchaField方法的典型用法代碼示例。如果您正苦於以下問題:Python fields.CaptchaField方法的具體用法?Python fields.CaptchaField怎麽用?Python fields.CaptchaField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在captcha.fields的用法示例。


在下文中一共展示了fields.CaptchaField方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from captcha import fields [as 別名]
# 或者: from captcha.fields import CaptchaField [as 別名]
def __init__(self, target_object, data=None, initial=None, parent=None, **kwargs):
        self.user = kwargs.pop('user', None)
        self.parent = parent
        if initial is None:
            initial = {}
        initial.update({'parent': self.parent})
        super(MPTTCommentForm, self).__init__(target_object, data=data, initial=initial, **kwargs)
        if self.user is not None:
            if self.user.is_authenticated:
                self.fields['email'].required = False
                self.fields['name'].required = False
            else:
                self.fields['captcha'] = CaptchaField()
        else:
            current_request = CrequestMiddleware.get_request()
            if current_request.user.is_authenticated:
                self.fields['email'].required = False
                self.fields['name'].required = False
            else:
                self.fields['captcha'] = CaptchaField() 
開發者ID:zmrenwu,項目名稱:django-mptt-comments,代碼行數:22,代碼來源:forms.py

示例2: get_captcha

# 需要導入模塊: from captcha import fields [as 別名]
# 或者: from captcha.fields import CaptchaField [as 別名]
def get_captcha():
    if getattr(settings, 'ENABLE_CAPTCHA', False):
        if getattr(settings, 'RECAPTCHA_PRIVATE_KEY', '') and getattr(settings, 'RECAPTCHA_PUBLIC_KEY', ''):
            from snowpenguin.django.recaptcha2.fields import ReCaptchaField
            from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget

            return ReCaptchaField(label='', widget=ReCaptchaWidget())
        else:
            from captcha.fields import CaptchaField

            return CaptchaField(label='')
    else:
        return None 
開發者ID:tethysplatform,項目名稱:tethys,代碼行數:15,代碼來源:forms.py


注:本文中的captcha.fields.CaptchaField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。