这是django-lazysignup forms.py:
from django.contrib.auth.forms import UserCreationForm as UserCreationFormBase
class UserCreationForm(UserCreationFormBase):
def get_credentials(self):
return {
'username': self.cleaned_data['username'],
'password': self.cleaned_data['password1']}
如何添加django-simple-catcha(http://django-simple-captcha.readthedocs.org/en/latest/)?我尝试了以下但当然不起作用;)
from django.contrib.auth.forms import UserCreationForm as UserCreationFormBase
from captcha.fields import CaptchaField
class UserCreationForm(UserCreationFormBase):
def get_credentials(self):
captcha = CaptchaField()
return {
'username': self.cleaned_data['username'],
'password': self.cleaned_data['password1'],
'captcha': captcha}
有关如何在此注册表单上添加验证码的任何提示?
答案 0 :(得分:0)
事实证明它就像
一样简单from django.contrib.auth.forms import UserCreationForm as UserCreationFormBase
from captcha.fields import CaptchaField
class UserCreationForm(UserCreationFormBase):
captcha = CaptchaField()
def get_credentials(self):
return {
'username': self.cleaned_data['username'],
'password': self.cleaned_data['password1']}
我使用Pillow并且还要安装libfreetype6-dev
。像魅力一样工作!