Skip to content

Commit

Permalink
Add a field type "simple captcha", which automatically appears when d…
Browse files Browse the repository at this point in the history
…jango-simple-capcha is installed in a django project.
  • Loading branch information
Martin J. Laubach committed Sep 25, 2024
1 parent 17af341 commit 91567d9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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
}
)

0 comments on commit 91567d9

Please sign in to comment.