1

我无法将 django-recaptcha 添加到注册表单。该表单是 django-registration 表单的扩展。这是我插入它的方法(仅显示相关代码):

网址.py:

from registration_custom.forms import RegistrationFormUniqueEmail

url(r'^accounts/register/$', 'registration_custom.views.register',
{'form_class':RegistrationFormUniqueEmail,
    'backend':'registration.backends.default.DefaultBackend' }, name='registration_register',),

*registration_custom.forms.py:*

from captcha.fields import ReCaptchaField 

class RegistrationFormUniqueEmail(RegistrationForm):
    """
    Subclass of ``RegistrationForm`` which enforces uniqueness of
    email addresses.

    """
    # added recaptcha
    captcha = ReCaptchaField()

    def clean_email(self):
        """
        Validate that the supplied email address is unique for the
        site.

        """
        if User.objects.filter(email__iexact=self.cleaned_data['email']):
        raise forms.ValidationError(_("This email address is already in use. Please supply a different email address."))
        return self.cleaned_data['email']

我已经检查过我的 recaptcha 密钥是否正确,并且它们是正确的,并且这些密钥是为我用来测试的域设置的。

你能发现我错过的东西吗?谢谢。

4

0 回答 0