My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
CaptchaConfiguration  
Updated Mar 11, 2010 by mbonetti

Django Simple Captcha

Configuration

The following configuration elements can be defined (in your settings.py)

CAPTCHA_FONT_PATH

Full path and filename of a TrueType (TTF), OpenType, or pilfont font file used to render text.

Defaults to: fonts/Vera.ttf (included in the application, GPL font).

Note that your PIL installation must support TTF and/or OpenFont if you want to use this kind of glyphs (most modern distributions of PIL do.)

CAPTCHA_FONT_SIZE

Font-size in pixels of the rendered text.

Defaults to '22'.

CAPTCHA_LETTER_ROTATION

A random rotation in this interval is applied to each letter in the challenge text.

Defaults to (-35,35).

New in version 0.1.6: set this to None to disable letter roation.

CAPTCHA_BACKGROUND_COLOR

Background-color of the captcha. Can be expressed as html-style #rrggbb, rgb(red, green, blue), or common html names (e.g. "red").

Defaults to: '#ffffff'

CAPTCHA_FOREGROUND_COLOR

Foreground-color of the captcha.

Defaults to '#001100'

CAPTCHA_CHALLENGE_FUNCT

String representing a python callable (i.e. a function) to use challenge generator.

See CaptchaGenerators for a list of available generators and a guide on how to write your own.

Defaults to: 'captcha.helpers.random_char_challenge'

CAPTCHA_NOISE_FUNCTIONS

List of strings of python callables that take a PIL DrawImage object and an Image iamge as input, modify the DrawImage, then return it.

Defaults to: ('captcha.helpers.noise_arcs','captcha.helpers.noise_dots',)

CAPTCHA_FILTER_FUNCTIONS

List of strings of python callables that take a PIL Image object as input, modify it and return it.

These are called right before the rendering, i.e. after the noise functions.

Defaults to: ('captcha.helpers.post_smooth',)

CAPTCHA_WORDS_DICTIONARY

Required for the word_challenge challenge function only. Points a file containing a list of words, one per line.

Defaults to: '/usr/share/dict/words'

CAPTCHA_FLITE_PATH

Full path to the flite executable. When defined, will automatically add audio output to the captcha.

Defaults to: None (no audio output)

CAPTCHA_TIMEOUT

Integer. Lifespan, in minutes, of the generated captcha.

Defaults to: 5

CAPTCHA_LENGTH

Sets the length, in chars, of the generated captcha. (for the 'captcha.helpers.random_char_challenge' challenge)

Defaults to: 4

CAPTCHA_DICTIONARY_MIN_LENGTH

When using the word_challenge challenge function, controls the minimum length of the words to be randomly picked from the dictionary file.

Defaults to: 0

CAPTCHA_DICTIONARY_MAX_LENGTH

When using the word_challenge challenge function, controls the maximal length of the words to be randomly picked from the dictionary file.

Defaults to: 99

Note: it's perfectly safe to specify e.g. CAPTCHA_DICTIONARY_MIN_LENGTH = CAPTCHA_DICTIONARY_MAX_LENGTH = 6 but it'd considered an error to define CAPTCHA_DICTIONARY_MAX_LENGTH to be smaller than CAPTCHA_DICTIONARY_MIN_LENGTH.

CAPTCHA_OUTPUT_FORMAT

New in version 0.1.6

Specify your own output format for the generated markup, when e.g. you want to position the captcha image relative to the text field in your form.

Defaults to: u'%(image)s %(hidden_field)s %(text_field)s'

Note: the three keys have to be present in the format string or an error will be thrown at runtime.

Comment by gonza.vi...@gmail.com, Mar 9, 2009

Hey, really great work you've done with this! Very useful, I'm using it in my next project...

Thanks

Comment by xxf4n...@gmail.com, Apr 12, 2009

I'm using this in my project as well. It'd be nice if it was easier to make the random_char challenge produce a longer string without hard coding it though. The change was easy to make, but I have to remember that I made that edit from now on. :) Love the project though, saved me a bunch of time.

Comment by Dido.Po...@gmail.com, Jul 11, 2009

It's really useful :)

Comment by fedor.ty...@gmail.com, Jul 20, 2009

Really easy to use! Thank you!

Comment by ewebe...@gmail.com, Sep 22, 2009

Really great work! Thank you Sir!!

Comment by yves.ven...@gmail.com, Nov 26, 2009

super simple to implement, thx!

Comment by rad...@gmail.com, Jan 13, 2010

I'm quite new to django, I've follow the procedure to install captcha, the form works but the browser don't load the image. I'm using the django development web server, and I think that can't serve the captcha images. Am I right? How can i make things work?

Thanks!

Comment by choudhar...@gmail.com, Jan 15, 2010

Check your urls.py and add '^captcha/' line properly, for me it was creating same problem.

Comment by real.spa...@gmail.com, Feb 7, 2010

Hello thank you for great Captcha we use it on http://userecho.com

Comment by martin.b...@gmail.com, Mar 20, 2010

Fantastic project! Followed the installation instructions and got it working with django-cms immediately. Where is the donation button :)

Comment by eva...@gmail.com, Mar 23, 2010

For those using Debian lenny, don't install the PIL dependency via easy_install PIL. Instead do sudo apt-get python-imaging. Didn't work until I deleted the egg that the former installed.

Comment by spit.jas...@gmail.com, Nov 9, 2010

Thanks ! Small question, how can I pass an attribute to the CaptchaField? so I can style it using css ?

Comment by darrenma...@gmail.com, Dec 10, 2010

Very nice. Small, quick and to the point but doing what it does well. Thanks for sharing.

Comment by michele.pasin, Jan 26, 2011

I can't get it to work django 1.1?: added everything as needed but the captcha form doesn't display.. I'm using it with django-cms, do u have any report of incompatibilities? (maybe due to the way the cms handles the urls..) p.s. I can go to /captcha/image/aaaa/ and get the error message 'No CaptchaStore? matches the given query.'.. so I guess the urls are wired up correctly. thanks..

Comment by jrgma...@gmail.com, Jan 26, 2011

I finally have everything working when Captcha is called from the test page. I was wondering however if anyone can give me some pointers on integrating CAPTCHA through a Django View (front end) through the views.py??

Thanks again for an EXCELLENT CAPTCHA option.

Comment by jmg....@gmail.com, May 30, 2011

Thank you. A great project. It was Very usefull and extremly simple to setup.

Comment by kost...@imagehawk.com, Jul 26, 2011

Very nice. Could I suggest changing captcha/views.py to use something like settings.CAPTCHA_IMAGE_FORMAT instead of hardcoding the image format and its content-type?

Comment by truefu...@gmail.com, Sep 5, 2011

Simple, Elegant, Efficient!!!

Comment by hlod...@gmail.com, Sep 29, 2011

Truly great!

Comment by quqiuf...@gmail.com, Dec 22, 2011

good job thank you!

Comment by nar...@districtclubs.com, Mar 9, 2012

great work. easy to set up. Thank you.


Sign in to add a comment
Powered by Google Project Hosting