Allow form field with required=False #264
-
I use django-recaptcha==1.4.0 It is possible return this behaviour? Or maybe there is a simple workaround how to handle my case? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Hello @un1t, we are sorry to hear you are having issues upgrading the django-recaptcha package. Unfortunately, we do not foresee allowing a required toggle on the field. The simplest way would be to just remove the captcha from the form's error list:
Other solutions include, but are not limited to; Not having the recaptcha field on the form by default and only adding it to the field list if the user needs it, subclassing the recaptcha field and overriding the init behavior, altering the form's full_clean, altering the form's is_valid, etc. |
Beta Was this translation helpful? Give feedback.
-
I'm having issues to test a view because captcha = ReCaptchaField(required=False) Doesn't work. I'm running automated tests and i would control required from a settings.py attribute |
Beta Was this translation helpful? Give feedback.
-
I'm facing this as well with recaptcha v3. v3 doesn't provide an input for the user, instead I would like to do v3 plus server side validation. I'm seeing some bots automate the POST to register users. you can just remove this line https://github.com/praekelt/django-recaptcha/blob/develop/captcha/fields.py#L47 |
Beta Was this translation helpful? Give feedback.
-
Hi. I contoured the issue with https://github.com/iogf/shiva/blob/master/ticket_app/forms.py |
Beta Was this translation helpful? Give feedback.
-
I sidestepped the form field altogether as I'm comfortable on frontend #217 |
Beta Was this translation helpful? Give feedback.
Hello @un1t, we are sorry to hear you are having issues upgrading the django-recaptcha package.
Unfortunately, we do not foresee allowing a required toggle on the field.
Adding a recaptcha field means one wants to protect a specific aspect of your site against abuse.
Wanting to make it optional must be a deliberate implementation change, not a mere toggle.
The simplest way would be to just remove the captcha from the form's error list: