基于django simple math captcha的wagtail表单页的简单数学验证码字段。

wagtail-simple-math-captcha的Python项目详细描述


基于django simple math captcha的wagtail表单页的简单数学验证码字段。

wagtail simple math captcha提供了一种集成 django-simple-math-captcha 以摇摆的形式。代码基于 wagtailsweetcaptcha

安装

  1. 安装wagtail-simple-math-captcha
  2. wagtailsimplemathcaptcha添加到 settings.py

用法

当您安装wagtail-simple-math-captcha时,将无法获得验证码 表单生成器中可用字段类型中的字段。利用它你 需要对MathCaptchaForm或^{tt7}进行子类划分$ (替换AbstractFormAbstractEmailForm 分别)。完成后,验证码字段将出现在 前端:

frommodelcluster.fieldsimportParentalKeyfromwagtail.wagtailadmin.edit_handlersimport(FieldPanel,InlinePanel,MultiFieldPanel)fromwagtail.wagtailcore.fieldsimportRichTextFieldfromwagtail.wagtailforms.modelsimportAbstractEmailForm,AbstractFormFieldfromwagtailsimplemathcaptcha.modelsimportMathCaptchaEmailFormclassFormField(AbstractFormField):page=ParentalKey('FormPage',related_name='form_fields')classFormPage(MathCaptchaEmailForm):intro=RichTextField(blank=True)thank_you_text=RichTextField(blank=True)# wagtail-simple-math-captcha configurationcaptcha_label=""captcha_help_text="Answer this question to prove you're human."FormPage.content_panels=[FieldPanel('title',classname="full title"),FieldPanel('intro',classname="full"),InlinePanel('form_fields',label="Form fields"),FieldPanel('thank_you_text',classname="full"),MultiFieldPanel([FieldPanel('to_address',classname="full"),FieldPanel('from_address',classname="full"),FieldPanel('subject',classname="full"),],"Email")]

可以配置字段的verbose_namehelp_text 属性,包括captcha_labelcaptcha_help_text 类中的属性或重写get_captcha_label()get_captcha_help_text()方法:

frommodelcluster.fieldsimportParentalKeyfromwagtail.wagtailadmin.edit_handlersimport(FieldPanel,InlinePanel,MultiFieldPanel)fromwagtail.wagtailcore.fieldsimportRichTextFieldfromwagtail.wagtailforms.modelsimportAbstractEmailForm,AbstractFormFieldfromwagtailsimplemathcaptcha.modelsimportMathCaptchaEmailFormclassFormField(AbstractFormField):page=ParentalKey('FormPage',related_name='form_fields')classFormPage(MathCaptchaEmailForm):intro=RichTextField(blank=True)thank_you_text=RichTextField(blank=True)# wagtail-simple-math-captcha configurationdefget_captcha_label(self):return""defget_captcha_help_text(self):return"Answer this question to prove you're human."FormPage.content_panels=[FieldPanel('title',classname="full title"),FieldPanel('intro',classname="full"),InlinePanel('form_fields',label="Form fields"),FieldPanel('thank_you_text',classname="full"),MultiFieldPanel([FieldPanel('to_address',classname="full"),FieldPanel('from_address',classname="full"),FieldPanel('subject',classname="full"),],"Email")]

captcha_labelcaptcha_help_text的默认值都是 emty string公司。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在表被注释到配置之前获取表的元数据?   java滚动条不会出现在JList上   java JOGL监视器GPU内存   java为什么要使用RecyclerView onDraw延迟   java定制Oppo Reno 2 Z CPH1951(手机型号)的固件(闪存文件)   java自定义线程池执行器   java如何解决发布版本中重复的jar条目[com/安卓/volley/R.class]?   java如何使用Bukkit API触发事件?   java在blazemeter jmeter RTE插件中使用ctrl+w输入   C#/Visual Studio的java JDT等价物   java为什么当maxread值很大而收到的消息数量很小时,卡夫卡消费者会无限期消费?   java游戏2。x:包含模板列表的绑定模型   带压缩的java日志旋转   运行时。exec用java运行程序读取它正在做什么