Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a field type "simple captcha", which automatically appears when … #42

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ field to the form designer. For everything else read through the
django-recaptcha readme.


Simple Captcha
==============

To enable `django-simple-captcha <https://pypi.org/project/django-simple-captcha>`__ install
`django-simple-captcha <https://pypi.org/project/django-simple-captcha>`__ and add
``captcha`` to your ``INSTALLED_APPS`` as described in the documentation for
``django-simple-captcha``. This will automatically add a "Simple Captcha"
field to the form designer field types.


Override field types
====================

Expand Down
16 changes: 16 additions & 0 deletions form_designer/default_field_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,19 @@ def require_choices(field):
"field": partial(ReCaptchaField, widget=ReCaptchaV3),
}
)


# Add django-simple-captcha field if available
if apps.is_installed("captcha"): # pragma: no cover
try:
from captcha.fields import CaptchaField
except ImportError:
pass
else:
FIELD_TYPES.append(
{
"type": "simple captcha",
"verbose_name": _("Simple CAPTCHA"),
"field": CaptchaField
}
)