I
I
Isaac Clark2012-07-21 14:25:11
Django
Isaac Clark, 2012-07-21 14:25:11

How to add Django Simple Captcha to template?

Hello.
Tell me please.
Downloaded Django Simple Captcha and started installing.

#forms.py
from captcha.fields import CaptchaField

class RegistrationForm(ModelForm):
    username     =    forms.CharField(label = (u'User Name'))
    email        =    forms.EmailField(label = (u'Email Address'))
    password     =    forms.CharField(label = (u'Password'), widget = forms.PasswordInput(render_value = False))
    password1    =    forms.CharField(label = (u'Verify Password'), widget = forms.PasswordInput(render_value = False))
    captcha      =    CaptchaField()    
    
    class Meta:
        model      =    Person
        exclude    =    ('user',)

#urls.py
urlpatterns += patterns('',
    url(r'^captcha/', include('captcha.urls')),
)

How can I display the captcha in the template?
Now I just write {{ form }}, but the captcha itself is not displayed, and a regular text field appears in its place ...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Korolev, 2012-07-21
@workDNK

1. In the installation description there is an item that PIL with FreeType support must be installed.
2. A similar problem is described here . In the answers to the question, it is advised to check through the test whether all the captcha dependencies are installed, to do this, go to the project directory and run the manage.py test captcha command , which will show if everything is ok.

D
Dmitry Korolev, 2012-07-21
@workDNK

Maybe django will give some additional information if you try to open the image directly at the src address of the img tag?

B
blazer05, 2019-02-20
@blazer05

I screwed this captcha on the site, everything works fine. One question, when a captcha is entered incorrectly, "Wrong answer" is displayed, where is it buried, I want to fix it for something of my own, but I can't find where it is recorded?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question