Django简单验证码一直在说“无效验证码”`

2024-05-16 22:07:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经按照医生给出的步骤, 首先,它工作得很好,但是,我不知道有什么不对的地方,它使 {cdan}。 我运行manage.py test captcha, 上面写着:

C:\Windows\system32\cmd.exe /c python.exe manage.py test captcha
Creating test database for alias 'default'...
.......Internal Server Error: /test/
Traceback (most recent call last):
  File "D:\Python33\lib\site-packages\django-1.5.5-py3.3.egg\django\core\handler
s\base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "D:\Python33\lib\site-packages\django_simple_captcha-0.4.1-py3.3.egg\capt
cha\tests\views.py", line 48, in test
    class CaptchaTestForm(forms.Form):
  File "D:\Python33\lib\site-packages\django_simple_captcha-0.4.1-py3.3.egg\capt
cha\tests\views.py", line 51, in CaptchaTestForm
    captcha = CaptchaField(help_text='asdasd')
  File "D:\Python33\lib\site-packages\django_simple_captcha-0.4.1-py3.3.egg\capt
cha\fields.py", line 107, in __init__
    kwargs['widget'] = kwargs.pop('widget', CaptchaTextInput(output_format=kwarg
s.pop('output_format', None)))
  File "D:\Python33\lib\site-packages\django_simple_captcha-0.4.1-py3.3.egg\capt
cha\fields.py", line 73, in __init__
    '%%(%s)s' % key
django.core.exceptions.ImproperlyConfigured: All of %(image)s, %(hidden_field)s,
 %(text_field)s must be present in your CAPTCHA_OUTPUT_FORMAT setting. Could not
 find %(hidden_field)s
Internal Server Error: /test-modelform/
Traceback (most recent call last):
  File "D:\Python33\lib\site-packages\django-1.5.5-py3.3.egg\django\core\handler
s\base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "D:\Python33\lib\site-packages\django_simple_captcha-0.4.1-py3.3.egg\capt
cha\tests\views.py", line 56, in test_model_form
    class CaptchaTestModelForm(forms.ModelForm):
  File "D:\Python33\lib\site-packages\django_simple_captcha-0.4.1-py3.3.egg\capt
cha\tests\views.py", line 59, in CaptchaTestModelForm
    captcha = CaptchaField(help_text='asdasd')
  File "D:\Python33\lib\site-packages\django_simple_captcha-0.4.1-py3.3.egg\capt
cha\fields.py", line 107, in __init__
    kwargs['widget'] = kwargs.pop('widget', CaptchaTextInput(output_format=kwarg
s.pop('output_format', None)))
  File "D:\Python33\lib\site-packages\django_simple_captcha-0.4.1-py3.3.egg\capt
cha\fields.py", line 73, in __init__
    '%%(%s)s' % key
django.core.exceptions.ImproperlyConfigured: All of %(image)s, %(hidden_field)s,
 %(text_field)s must be present in your CAPTCHA_OUTPUT_FORMAT setting. Could not
 find %(hidden_field)s
............

我用谷歌搜索了一段时间,但没有找到任何结果。 CAPTCHA_OUTPUT_FORMAT中可能有问题 还有%(hidden_field)s,但我不知道怎么解决它?在

我对此感到厌烦。当我在captcha中运行py时,它是这样写的:

^{pr2}$

我继续找不到重复的验证码, 有人帮忙吗?在


Tags: djangoinpytestegglibpackagesline
2条回答

这是因为我删除了windows中的globle var='DJANGO_SETTINGS_MODULE',我认为这没什么大用处。我把它放在窗户里。 测试最后显示OK,这意味着上面的两个警告不是很重要。 但是在我修复了revalidation in formwizard and single validation in captcha之后,测试显示出很多错误,而我ignores它。 这个问题要给我三天甚至更多的时间,这是必须写下来以供纪念的。在

请查看以下网址。从第10次谈话开始讨论同样的问题。在

https://github.com/mbi/django-simple-captcha/issues/41

以上链接提供的可能解决方案-

  • 您是否在全局和虚拟环境中都安装了此库?在

    如果是,则卸载不需要的。

  • 您是否在设置中重新定义了“验证码输出格式”?在

    如果是,则在注释该行之后进行测试。

相关问题 更多 >