2
我在我的Django應用程序中使用包django-simple-captcha
。如何在Django中以脆弱的形式添加CaptchaField()?
的documentation指出,添加在表單驗證碼現場,所有你需要做的是
from django import forms
from captcha.fields import CaptchaField
class CaptchaTestForm(forms.Form):
myfield = AnyOtherField()
captcha = CaptchaField()
但是,我怎麼使用這樣的字段,如果我的形式是香脆的形式,這是如下 -
class SignupForm(authtoolsforms.UserCreationForm):
def __init__(self, *args, **kwargs):
super(SignupForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.fields["email"].widget.input_type = "email"
self.helper.layout = Layout(
Field('email', placeholder="Enter Email", autofocus=""),
Field('name', placeholder="Enter Full Name"),
Field('password1', placeholder="Enter Password"),
Field('password2', placeholder="Re-enter Password"),
Field('gender', placeholder="Gender"),
Submit('sign_up', 'Sign up', css_class="btn-warning"),
)