zmh-program/django-turnstile

Support for invisible widget type

Closed this issue ยท 5 comments

Thank you, Minghan, for this very useful project. Bravo! ๐Ÿ‘

I would like to use Turnstile's invisible widget type, but it is not clear to me how to configure django-turnstile to use the invisible widget type. Could you possibly provide some guidance?

First of all, thank you very much for your advice, this is my first issue! ๐Ÿ˜ƒ

I browsed the turnstile docs and CloudFlare community, and as you can see, I didn't find anything specific about invisible widgets. ๐Ÿ˜“
I'm trying to decompile and read the turnstile source code to find something useful. ๐Ÿค”

Hope everything goes well. ๐Ÿ‘€

(Sorry, please excuse my English)

Wait...
I think I found something useful...
image
image

It looks like it's the param size ๐Ÿค”
Wait for success! ๐Ÿ˜„

Yes, that's right!
image

I have already successfully implemented an instance, and both the frontend and the backend are fine! ๐Ÿ˜ƒ

Let me tell you how you should change your code:

- Global Configuration

<project> / settings.py

TURNSTILE_DEFAULT_CONFIG = {
    'size': 'invisible',   # add it
}

or

- Local Configuration

... / forms.py

from django import forms


class ExampleForm(forms.Form):
    captcha = CaptchaField(
        label="captcha",
        size="invisible",   # add it
        error_messages={
            "required": "Please enter the captcha field",
            "invalid": "The captcha is incorrect"
        },
    )

Thanks for the issue! If you are also successful, please comment and then I will close the issue~

Hey Zhang. I just wanted to say a belated thank-you for responding to my question so quickly and for answering it so thoughtfully and thoroughly. Much, much appreciated! ๐Ÿ’•