oTree Forum >

ReCaptcha v2 in oTree 5

#1 by mitnec

Hi everyone,

I'm interested in using a captcha of some sort (there are a lot of scammers out there). I understand that oTree>5 isn't really django any more. Is there a way to do this?

Following https://github.com/chkgk/otree_recaptcha results in 
django.core.exceptions.ImproperlyConfigured: Requested setting RECAPTCHA_DOMAIN, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

...which seems to make sense since we don't have the whole suite of django settings files, etc. Is this tenable in oTree >5?

#2 by Chris_oTree

Yes anything Django-based won't work in oTree Lite.

There is a readymade app in otree-realeffort with various captcha-like tasks: https://www.otreehub.com/projects/otree-realeffort/

I think that will be the easiest solution.

If you want to use ReCAPTCHA specifically, you can follow the instructions here: https://developers.google.com/recaptcha/docs/v3

In the part where it says "Add your logic to submit to your backend server here.", you would execute a liveSend with the user's submission, then in your live_method, use Python's "requests" library to make a request to Google's server.

Write a reply

Set forum username