Question

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
............

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?

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?

Was it helpful?

Solution

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.

  • Did you redefined "CAPTCHA_OUTPUT_FORMAT" in your settings?

    if yes then test after commenting that line.

OTHER TIPS

this is because i've delete the globle var='DJANGO_SETTINGS_MODULE' in my windows ,which i think is of not a big use. and i reset it in windows. and the test finally says OK,meaning the 2 warnings above not very important. but after i fix the revalidation in formwizard and single validation in captcha, tests shows plenty errors ,and i ignoresit. this question annoies me three or more days ,whick had to be writen for remember.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top