Skip to main content

Django hCaptcha Field provides a simple way to protect your Django forms using hCaptcha.

Project description

Django hCaptcha Field

Python unit tests Linters

Django hCaptcha Field provides a simple way to protect your Django forms using hCaptcha.

This is a fork of django-hcaptcha.

Installation

  1. Install using pip:

    $ pip install django-hcaptcha-field
    
  2. Add to INSTALLED_APPS:

    INSTALLED_APPS = [
        # ...
        'hcaptcha_field'
    ]
    

Configuration

For development purposes no further configuration is required. By default, Django hCaptcha Field will use test keys.

For production, you'll need to obtain your hCaptcha site key and secret key and add them to you settings:

HCAPTCHA_SITEKEY = '<your sitekey>'
HCAPTCHA_SECRET = '<your secret key>'

You can also configure your hCaptcha widget globally (see all options):

HCAPTCHA_DEFAULT_CONFIG = {
    'onload': 'name_of_js_function',
    'render': 'explicit',
    'theme': 'dark',  # do not use data- prefix
    'size': 'compact',  # do not use data- prefix
    # ...
}

If you need to, you can also override default hCaptcha endpoints:

HCAPTCHA_JS_API_URL = 'https://hcaptcha.com/1/api.js'
HCAPTCHA_VERIFY_URL = 'https://hcaptcha.com/siteverify'

Use proxies:

HCAPTCHA_PROXIES = {
   'http': 'http://127.0.0.1:8000',
}

Change default verification timeout:

HCAPTCHA_TIMEOUT = 5

Usage

Simply add hCaptchaField to your forms:

from hcaptcha_field import hCaptchaField

class Form(forms.Form):
    hcaptcha = hCaptchaField()

You can override the sitekey and other default configuration by passing additional arguments:

from hcaptcha_field import hCaptchaField

class Form(forms.Form):
    hcaptcha = hCaptchaField(sitekey='...', theme='dark', size='compact')

License

The scripts and documentation in this project are released under the BSD-3-Clause License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-hcaptcha-field-1.2.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

django_hcaptcha_field-1.2.2-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file django-hcaptcha-field-1.2.2.tar.gz.

File metadata

  • Download URL: django-hcaptcha-field-1.2.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for django-hcaptcha-field-1.2.2.tar.gz
Algorithm Hash digest
SHA256 949ef75a0bf90d7d9ec4d6176a69b1dfcb188daba95bcc5a37bfefeadec4c861
MD5 175e70e5faf720e9fa915cd725c75e49
BLAKE2b-256 c8e9403f17b5fd0cfd06a2359e8c6ca965af797f65df3bac5ff98e003113dbf3

See more details on using hashes here.

File details

Details for the file django_hcaptcha_field-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_hcaptcha_field-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ec2215489e1e06dbd7141475e66f9deccc26d433225019b01f92bc3bbcd3920d
MD5 1f347434444591db12cca93c07876b0d
BLAKE2b-256 5863ad1f840611595f06d1cabd91d149226faeb00c30afb0bc436df232412ce1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page