易于使用的django验证码或注册应用程序与验证码? [英] Easy-to-use django captcha or registration app with captcha?

查看:162
本文介绍了易于使用的django验证码或注册应用程序与验证码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Django中使用captcha实现用户注册。
django-registration 应用程序的工作流程非常好,但它没有验证码。

I want to implement user registration using captcha in Django. The workflow of django-registration app is a great, but it doesn't have captcha.

您建议使用什么验证码?
还有其他一些变体的注册+验证码或有用的链接主题?

What captcha would you recommend to use with it? Are there some other variants of registration+captcha or useful links on the topic?

这应该适用于Django-1.1,不要太难安装。

This should work with Django-1.1 and don't be too hard to install.

推荐答案

django注册是相当可扩展的。扩展它的一种方法是提供一个自定义的注册表单。我建议使用 reCaptcha ,例如来自此处的小部件和表单字段(存档)。那么就像写一个自定义表单类和注册后端一样简单(这比它听起来更简单):

django-registration is pretty extendable. One way to extend it is to provide a custom registration form. I'd recommend to use reCaptcha, e.g. with the widget and form field from here (archived). Then it is as simple as writing a custom form class and registration backend (which is simpler than it sounds):

from registration.backends.default import DefaultBackend
from registration.forms import RegistrationForm

class RecaptchaRegistrationForm(RegistrationForm)
    recaptcha = ReCaptchaField(label="I'm a human")

class RecaptchaRegistrationBackend(DefaultBackend):
    def get_form_class(self, request):
        return RecaptchaRegistrationForm

最后一步是告诉django注册使用你的后端。该步骤在 docs (我找不到文档的HTML版本,抱歉)

The last step is to tell django-registration to use your backend. That step is described in the docs (I couldn't find a HTML version of the docs, sorry)

这篇关于易于使用的django验证码或注册应用程序与验证码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆