django-friendly-captcha


Namedjango-friendly-captcha JSON
Version 0.1.10 PyPI version JSON
download
home_pagehttps://github.com/christianwgd/django-friendly-captcha
SummaryDjango library for friendly captcha
upload_time2024-03-29 09:40:22
maintainerChristian Wiegand
docs_urlNone
authorChristian Wiegand
requires_pythonNone
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Django Friendly Captcha
=======================

.. image:: https://img.shields.io/pypi/v/django-friendly-captcha
    :target: https://pypi.python.org/pypi/django-friendly-captcha

.. image:: https://img.shields.io/pypi/dm/django-friendly-captcha
    :alt: PyPI - Downloads
    :target: https://pypi.python.org/pypi/django-friendly-captcha

Django field/widget for Friendly Captcha (https://friendlycaptcha.com).



Installation
------------

Latest version:

    pip install -e git+git://github.com/christianwgd/django-friendly-captcha.git#egg=django-friendly-captcha

Stable version:

    pip install django-friendly-captcha

Documentation
-------------

Usage
#####

Add 'friendly_captcha' to your INSTALLED_APPS.

.. code-block::

    INSTALLED_APPS = [
        ...
        'friendly_captcha',
    ]

Add the captcha field to your form:

.. code-block::

    from friendly_captcha.fields import FrcCaptchaField


    class ContactForm(forms.ModelForm):

        class Meta:
            model = ContactMessage
            fields = (
                'name', 'email', 'subject', 'text'
            )

        captcha = FrcCaptchaField()

As of version 0.1.7 the javascript static assets are included in
the widget, so there is no need to do that in your project templates.
Version 0.1.10 includes friendly captcha version 0.9.15 javascript files.
If you need a different version you can set these by providing
them in your settings:

.. code-block::

    FRC_WIDGET_MODULE_JS = 'https://unpkg.com/friendly-challenge@0.9.8/widget.module.min.js'
    FRC_WIDGET_JS = 'https://unpkg.com/friendly-challenge@0.9.8/widget.min.js'

For version 0.1.6 and below you need to include the script tags from
Friendly Captcha to your forms template
(see https://docs.friendlycaptcha.com/#/installation)

.. code-block::

    <script type="module" src="https://unpkg.com/friendly-challenge@0.9.8/widget.module.min.js" async defer></script>
    <script nomodule src="https://unpkg.com/friendly-challenge@0.9.8/widget.min.js" async defer></script>

If you build up your form from single fields, dont't forget to include
the captcha form field.

Configuration
#############

Register to Friendly Captcha at https://friendlycaptcha.com/signup to get your
sitekey and captcha secret.

.. code-block::

    FRC_CAPTCHA_SECRET = '<yourCaptchaSecret'
    FRC_CAPTCHA_SITE_KEY = '<yourCaptchaSiteKey>'

.. code-block::

    FRC_CAPTCHA_VERIFICATION_URL = 'https://api.friendlycaptcha.com/api/v1/siteverify'

In default the form will fail with an error ('Captcha test failed'). You can change
this behaviour by setting FRC_CAPTCHA_FAIL_SILENT to True.

.. code-block::

    FRC_CAPTCHA_FAIL_SILENT = False

When setting FAIL_SILENT to True it's up to you to handle captcha verification:

.. code-block::

    # in your form view
    def form_valid(self, form):
        captcha_verified = form.cleaned_data['captcha']
        if captcha_verified:
            # send mail or whatever ...
        else:
            # captcha verification failed, do nothing ...

Custom widget attributes
########################

You can add custom widget attrs to the FrcCaptchaField like in any other
Django field:

.. code-block::

    captcha = FrcCaptchaField(widget=FrcCaptchaWidget(attrs={'data-start': 'auto'}))

See https://docs.friendlycaptcha.com/#/widget_api for additional widget attrs.
The data-lang attr is set from your Django configured language.

Logging
#######

If you want to log the results of the captcha verifications you can
add a logger to your logging configuration:

.. code-block::

    'django.friendly_captcha': {
        'handlers': ['default'],
        'level': 'INFO',
    }

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/christianwgd/django-friendly-captcha",
    "name": "django-friendly-captcha",
    "maintainer": "Christian Wiegand",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "christianwgd@gmail.com",
    "keywords": null,
    "author": "Christian Wiegand",
    "author_email": "christianwgd@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b4/d8/68e3b61a0bfe91aa04e3415e9c4ba6006edb24a4a7a3f7be198a006bedc4/django-friendly-captcha-0.1.10.tar.gz",
    "platform": null,
    "description": "Django Friendly Captcha\n=======================\n\n.. image:: https://img.shields.io/pypi/v/django-friendly-captcha\n    :target: https://pypi.python.org/pypi/django-friendly-captcha\n\n.. image:: https://img.shields.io/pypi/dm/django-friendly-captcha\n    :alt: PyPI - Downloads\n    :target: https://pypi.python.org/pypi/django-friendly-captcha\n\nDjango field/widget for Friendly Captcha (https://friendlycaptcha.com).\n\n\n\nInstallation\n------------\n\nLatest version:\n\n    pip install -e git+git://github.com/christianwgd/django-friendly-captcha.git#egg=django-friendly-captcha\n\nStable version:\n\n    pip install django-friendly-captcha\n\nDocumentation\n-------------\n\nUsage\n#####\n\nAdd 'friendly_captcha' to your INSTALLED_APPS.\n\n.. code-block::\n\n    INSTALLED_APPS = [\n        ...\n        'friendly_captcha',\n    ]\n\nAdd the captcha field to your form:\n\n.. code-block::\n\n    from friendly_captcha.fields import FrcCaptchaField\n\n\n    class ContactForm(forms.ModelForm):\n\n        class Meta:\n            model = ContactMessage\n            fields = (\n                'name', 'email', 'subject', 'text'\n            )\n\n        captcha = FrcCaptchaField()\n\nAs of version 0.1.7 the javascript static assets are included in\nthe widget, so there is no need to do that in your project templates.\nVersion 0.1.10 includes friendly captcha version 0.9.15 javascript files.\nIf you need a different version you can set these by providing\nthem in your settings:\n\n.. code-block::\n\n    FRC_WIDGET_MODULE_JS = 'https://unpkg.com/friendly-challenge@0.9.8/widget.module.min.js'\n    FRC_WIDGET_JS = 'https://unpkg.com/friendly-challenge@0.9.8/widget.min.js'\n\nFor version 0.1.6 and below you need to include the script tags from\nFriendly Captcha to your forms template\n(see https://docs.friendlycaptcha.com/#/installation)\n\n.. code-block::\n\n    <script type=\"module\" src=\"https://unpkg.com/friendly-challenge@0.9.8/widget.module.min.js\" async defer></script>\n    <script nomodule src=\"https://unpkg.com/friendly-challenge@0.9.8/widget.min.js\" async defer></script>\n\nIf you build up your form from single fields, dont't forget to include\nthe captcha form field.\n\nConfiguration\n#############\n\nRegister to Friendly Captcha at https://friendlycaptcha.com/signup to get your\nsitekey and captcha secret.\n\n.. code-block::\n\n    FRC_CAPTCHA_SECRET = '<yourCaptchaSecret'\n    FRC_CAPTCHA_SITE_KEY = '<yourCaptchaSiteKey>'\n\n.. code-block::\n\n    FRC_CAPTCHA_VERIFICATION_URL = 'https://api.friendlycaptcha.com/api/v1/siteverify'\n\nIn default the form will fail with an error ('Captcha test failed'). You can change\nthis behaviour by setting FRC_CAPTCHA_FAIL_SILENT to True.\n\n.. code-block::\n\n    FRC_CAPTCHA_FAIL_SILENT = False\n\nWhen setting FAIL_SILENT to True it's up to you to handle captcha verification:\n\n.. code-block::\n\n    # in your form view\n    def form_valid(self, form):\n        captcha_verified = form.cleaned_data['captcha']\n        if captcha_verified:\n            # send mail or whatever ...\n        else:\n            # captcha verification failed, do nothing ...\n\nCustom widget attributes\n########################\n\nYou can add custom widget attrs to the FrcCaptchaField like in any other\nDjango field:\n\n.. code-block::\n\n    captcha = FrcCaptchaField(widget=FrcCaptchaWidget(attrs={'data-start': 'auto'}))\n\nSee https://docs.friendlycaptcha.com/#/widget_api for additional widget attrs.\nThe data-lang attr is set from your Django configured language.\n\nLogging\n#######\n\nIf you want to log the results of the captcha verifications you can\nadd a logger to your logging configuration:\n\n.. code-block::\n\n    'django.friendly_captcha': {\n        'handlers': ['default'],\n        'level': 'INFO',\n    }\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Django library for friendly captcha",
    "version": "0.1.10",
    "project_urls": {
        "Homepage": "https://github.com/christianwgd/django-friendly-captcha"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2b8554f27d99e93962e6ceea18bff88b2d43b4631dfe979806c2d1e42e32350b",
                "md5": "71ddef65ba87ee93046d7466355d92de",
                "sha256": "586e865cd5c0c2ac0a2c3d8fa76a1047d93b659517e8b0fa4bf2e083dd3a1811"
            },
            "downloads": -1,
            "filename": "django_friendly_captcha-0.1.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "71ddef65ba87ee93046d7466355d92de",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8706,
            "upload_time": "2024-03-29T09:40:20",
            "upload_time_iso_8601": "2024-03-29T09:40:20.935476Z",
            "url": "https://files.pythonhosted.org/packages/2b/85/54f27d99e93962e6ceea18bff88b2d43b4631dfe979806c2d1e42e32350b/django_friendly_captcha-0.1.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4d868e3b61a0bfe91aa04e3415e9c4ba6006edb24a4a7a3f7be198a006bedc4",
                "md5": "ab49a3ee63e9e47bc711600978b060c0",
                "sha256": "10e01599fd81e7cae7775caa5466aae10d9c9f1f387ca526e45015b7f483902f"
            },
            "downloads": -1,
            "filename": "django-friendly-captcha-0.1.10.tar.gz",
            "has_sig": false,
            "md5_digest": "ab49a3ee63e9e47bc711600978b060c0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6085,
            "upload_time": "2024-03-29T09:40:22",
            "upload_time_iso_8601": "2024-03-29T09:40:22.722278Z",
            "url": "https://files.pythonhosted.org/packages/b4/d8/68e3b61a0bfe91aa04e3415e9c4ba6006edb24a4a7a3f7be198a006bedc4/django-friendly-captcha-0.1.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-29 09:40:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "christianwgd",
    "github_project": "django-friendly-captcha",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-friendly-captcha"
}
        
Elapsed time: 0.45766s