Skip to main content

Django reCAPTCHA form field/widget integration app.

https://travis-ci.org/EnTeQuAk/nobot.svg?branch=master https://badge.fury.io/py/nobot.png https://pypip.in/d/nobot/badge.png

Installation

  1. Install or add nobot to your Python path.

  2. Add nobot to your INSTALLED_APPS setting.

  3. Add a NOBOT_RECAPTCHA_PUBLIC_KEY setting to the project’s settings.py file. This is your public API key as provided by reCAPTCHA, i.e.:

    NOBOT_RECAPTCHA_PUBLIC_KEY = '76wtgdfsjhsydt7r5FFGFhgsdfytd656sad75fgh'

    This can be seperately specified at runtime by passing a public_key parameter when constructing the ReCaptchaField, see field usage below.

  4. Add a NOBOT_RECAPTCHA_PRIVATE_KEY setting to the project’s settings.py file. This is your private API key as provided by reCAPTCHA, i.e.:

    NOBOT_RECAPTCHA_PRIVATE_KEY = '98dfg6df7g56df6gdfgdfg65JHJH656565GFGFGs'

    This can be seperately specified at runtime by passing a private_key parameter when constructing the ReCaptchaField, see field usage below.

Usage

Field

The quickest way to add reCAPTHCA to a form is to use the included ReCaptchaField field type. A ReCaptcha widget will be rendered with the field validating itself without any further action required from you. For example:

from django import forms
from nobot.fields import ReCaptchaField

class FormWithCaptcha(forms.Form):
    captcha = ReCaptchaField()

The reCAPTCHA widget supports several Javascript options variables customizing the behaviour of the widget, such as theme and lang. You can forward these options to the widget by passing an attr parameter containing a dictionary of options to ReCaptchaField, i.e.:

captcha = ReCaptchaField(attrs={'theme' : 'clean'})

The captcha client takes the key/value pairs and writes out the RecaptchaOptions value in JavaScript.

Testing

To obtain a valid form containing a reCAPTCHA field offline one can mock the verify method of ReCaptchaClient or HumanCaptchaClient, i.e.:

import mock
from nobot.client import RecaptchaResponse

class MyTestClass:

    @mock.patch('nobot.client.HumanCaptchaClient.verify')
    def test_with_valid_form(self, nobot_mock):
        nobot_mock.return_value = RecaptchaResponse(is_valid=True, error_code=None)

        # ...
        # Test your form or view
        # recaptcha won't 'spoil' test validation offline now

Credits

Originally developed under the name django-recaptcha by Praekelt Consulting. Forked for better testability and extensibility. Authors =======

nobot was previously developed under the name django-recaptcha and under the Copyright of Praekelt Foundation. The following copyright notice holds true for releases before the renaming: “Copyright (c) by Praekelt Foundation

Package Maintainer

  • Christopher Grebs

Praekelt Consulting

  • Shaun Sephton

  • Peter Pistorius

  • Hedley Roos

bTaylor Design

Other

Metadata

Release files for nobot 0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nobot 0.7
File Size Uploaded
nobot-0.7.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nobot 0.7
File Interpreter ABI Platform
nobot-0.7-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 23.6 kB

Release files / nobot-0.7.tar.gz

Download URL nobot-0.7.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
12c0ad7d62ad0eb65456ba88e796a5dcb21b13d940f71f4bcb28d4f84cb0106a
BLAKE2b-256 checksum
How to use checksums
9c57e813d603f778f0cb6f75aeffdb085e8c65daa5b1b32789b9fba973826835
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

Release files / nobot-0.7-py2.py3-none-any.whl

Download URL nobot-0.7-py2.py3-none-any.whl
Size 11.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a724b877bbb6ad2c9614a6461c86125ab950c4e8a9ce27355d39703409dedb6a
BLAKE2b-256 checksum
How to use checksums
d3f750f173175039149bc42edbe056f1101c03fbbb997adade8695de259daeb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

Release history Release notifications | RSS feed

This release

0.7 This release

2 release files

0.6

2 release files

0.5

2 release files

0.4.1

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page