コード例 #1
0
 class CheckboxAttrForm(forms.Form):
     captcha = fields.ReCaptchaField(
         widget=widgets.ReCaptchaV2Checkbox(attrs={
             "data-theme": "dark",
             "data-callback": "customCallback",
             "data-size": "compact"
         },
                                            api_params={"hl": "af"}))
コード例 #2
0
class UserLoginForm(AuthenticationForm):
    username = forms.CharField(
        label='Имя аккаунта',
        widget=forms.TextInput(attrs={'class': 'form-control'}))
    password = forms.CharField(
        label='Пароль',
        widget=forms.PasswordInput(attrs={'class': 'form-control'}))

    captcha = fields.ReCaptchaField(label='Капча',
                                    widget=widgets.ReCaptchaV2Checkbox())

    class Meta:
        model = User
        fields = ('username', 'password')
コード例 #3
0
class UserRegisterForm(UserCreationForm):
    email = forms.EmailField()
    captcha = ReCaptchaField(
        widget=widgets.ReCaptchaV2Checkbox()
    )

    class Meta:
        model = User
        fields = ['username', 'email', 'password1', 'password2', 'captcha']

    def __init__(self, *args, **kwargs):
        super(UserRegisterForm, self).__init__(*args, **kwargs)
        self.fields['username'].help_text = 'Može sadržavati maksimalno 150 znakova. Dopuštena su slova, brojevi i znakovi: <b>@ . + - _</b>'
        self.fields['password1'].help_text = 'Lozinka mora sadržavati minimalno 8 znakova, a ne smije ' \
                                             'sadržavati samo brojeve.'
        self.fields['password2'].help_text = 'Unesite istu lozinku, za potvrdu.'
コード例 #4
0
class UserRegisterForm(UserCreationForm):
    username = forms.CharField(label='Имя аккаунта',
                               max_length=18,
                               widget=forms.TextInput(attrs={
                                   'class': 'form-control',
                                   'autocomplete': 'off'
                               }))

    password1 = forms.CharField(
        label='Пароль',
        widget=forms.PasswordInput(attrs={'class': 'form-control'}))
    password2 = forms.CharField(
        label='Подтвердите пароль',
        widget=forms.PasswordInput(attrs={'class': 'form-control'}))

    captcha = fields.ReCaptchaField(label='Капча',
                                    widget=widgets.ReCaptchaV2Checkbox())

    class Meta:
        model = User
        fields = ('username', 'password1', 'password2')
コード例 #5
0
class ContactForm(forms.Form):
    name = forms.CharField(
        max_length=127,
        required=True,
        label='Your Name',
        widget=forms.TextInput(attrs={'class': 'form-control'}),
    )
    email = forms.EmailField(
        required=True,
        label='Your Email',
        widget=forms.EmailInput(attrs={'class': 'form-control'}),
    )
    subject = forms.CharField(
        max_length=127,
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control'}),
    )
    message = forms.CharField(
        required=True,
        widget=forms.Textarea(attrs={'class': 'form-control'}),
    )
    captcha = fields.ReCaptchaField(
        widget=widgets.ReCaptchaV2Checkbox()
    )

    def save(self):
        email = EmailMessage(
            self.cleaned_data['subject'],
            self.cleaned_data['message'],
            f"{self.cleaned_data['name']} <{self.cleaned_data['email']}>",
            ['*****@*****.**'],
            reply_to=[self.cleaned_data['email']]
        )
        try:
            email.send(fail_silently=False)
            return True, ''
        except Exception as e:
            return False, e
コード例 #6
0
ファイル: forms.py プロジェクト: anuchit1999/testDjango
    captcha = ReCaptchaField(widget=ReCaptchaV2Invisible)


captcha = ReCaptchaField(
    public_key='6Lcb8uMUAAAAAAuiV5Ybj5CegQZzoUcx6FeHLm1C',
    private_key='6Lcb8uMUAAAAAPx4sL7qgZFp3AuwYUWAJ17uTVpy',
)


class FormWithCaptcha(forms.Form):
    captcha = ReCaptchaField(widget=ReCaptchaV2Invisible)


captcha = fields.ReCaptchaField(widget=widgets.ReCaptchaV2Checkbox(
    attrs={
        'data-theme': 'dark',
        'data-size': 'compact',
    }))
# The ReCaptchaV2Invisible widget
# ignores the "data-size" attribute in favor of 'data-size="invisible"'

captcha = fields.ReCaptchaField(widget=widgets.ReCaptchaV2Checkbox(
    api_params={
        'hl': 'cl',
        'onload': 'onLoadFunc'
    }))
# The dictionary is urlencoded and appended to the reCAPTCHA api url.

captcha = fields.ReCaptchaField(widget=ReCaptchaV2Invisible(
    attrs={
        'required_score': 0.85,
コード例 #7
0
 class DomainForm(forms.Form):
     captcha = fields.ReCaptchaField(
         widget=widgets.ReCaptchaV2Checkbox())