Python 如何在Django中以简洁的形式添加CaptchaField()?
我正在我的django应用程序中使用包Python 如何在Django中以简洁的形式添加CaptchaField()?,python,django,Python,Django,我正在我的django应用程序中使用包django simple captcha 声明说,要在表单中添加captcha字段,只需 from django import forms from captcha.fields import CaptchaField class CaptchaTestForm(forms.Form): myfield = AnyOtherField() captcha = CaptchaField() 但是,如果我的表单是脆表单,我如何使用该字段,如
django simple captcha
声明说,要在表单中添加captcha字段,只需
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"),
)
class SignupForm(authtoolsforms.UserCreationForm):
captcha = CaptchaField()
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"),
Field('captcha ', placeholder="Enter captcha"),
Submit('sign_up', 'Sign up', css_class="btn-warning"),
)