django简单的验证码不断说“无效CAPTCHA” [英] django simple captcha keeps saying `invalid CAPTCHA`
问题描述
我按照文档给出的步骤,
首先,它的效果很好,但是我不知道任何错误,它使
一个无效的Captcha
。
i运行 manage.py test captcha
,
它这样说:
I have followed the steps given by the docs,
firstly , it works well ,but ,i don't know anythings wrong ,it makes
an invalid Captcha
.
i run the manage.py test captcha
,
it says like this :
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
............
和我google一段时间,但没有找到任何结果。
可能在 CAPTCHA_OUTPUT_FORMAT
和%(hidden_field)s
中出现问题,但我不知道如何解决它?
and i google a while ,but do not find any results.
there may be something wrong in the CAPTCHA_OUTPUT_FORMAT
and %(hidden_field)s
,but i don't know how to solve it?
,我很无聊,当我在验证码中运行一个py,它就像这样:
and i was bored with it .and when i run a py in captcha,it says like this :
C:\Windows\system32\cmd.exe /c python.exe fields.py
Traceback (most recent call last):
File "D:\Python33\Lib\os.py", line 673, in __getitem__
value = self._data[self.encodekey(key)]
KeyError: 'DJANGO_SETTINGS_MODULE'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Python33\lib\site-packages\django-1.5.5-py3.3.egg\django\conf\__init_
_.py", line 37, in _setup
settings_module = os.environ[ENVIRONMENT_VARIABLE]
File "D:\Python33\Lib\os.py", line 676, in __getitem__
raise KeyError(key)
KeyError: 'DJANGO_SETTINGS_MODULE'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "fields.py", line 1, in <module>
\ufefffrom captcha.conf import settings
File "D:\Python33\lib\site-packages\django_simple_captcha-0.4.1-py3.3.egg\capt
cha\conf\settings.py", line 5, in <module>
CAPTCHA_FONT_PATH = getattr(settings, 'CAPTCHA_FONT_PATH', os.path.normpath(
os.path.join(os.path.dirname(__file__), '..', 'fonts/Vera.ttf')))
File "D:\Python33\lib\site-packages\django-1.5.5-py3.3.egg\django\conf\__init_
_.py", line 53, in __getattr__
self._setup(name)
File "D:\Python33\lib\site-packages\django-1.5.5-py3.3.egg\django\conf\__init_
_.py", line 46, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting CAPTCHA_FONT_PATH
, but settings are not configured. You must either define the environment variab
le DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings
.
shell returned 1
我继续找不到重复的验证码,
任何一个帮助?
there i continue can not find the duplicated captcha, any one help?
推荐答案
请查看以下URL。从第十个对话中讨论同样的问题。
Please look into the below URL. From 10th conversation same problem is discussed.
https://github.com/mbi/django-simple-captcha/issues/41
上述链接中提供的可能解决方案 -
Possible solutions provided in above link -
-
您是否还将这个库安装在全局和虚拟环境中?
Do you also have this library installed in both global as well as virtual environments?
如果是,则卸载不需要的那个。
if Yes then uninstall the one which is not required.
您是否重新定义了CAPTCHA_OUTPUT_FORMAT在您的设置中?
Did you redefined "CAPTCHA_OUTPUT_FORMAT" in your settings?
如果是,则在评论该行后进行测试。
if yes then test after commenting that line.
这篇关于django简单的验证码不断说“无效CAPTCHA”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!