Use @check_recaptcha
on your POST handler_function
settings.py
GOOGLE_RECAPTCHA_SECRET_KEY = 'your-server-key'
views.py
from djlotrek.decorators import check_recaptcha
@check_recaptcha
def my_view(request):
if request.recaptcha_is_valid:
print('Recaptcha is valid, go on')
else:
print("you are a robot, and we don't like robot")
your-template.html
<form method="POST">
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="your-client-key"></div>
</form>
https://www.google.com/recaptcha/admin/create
If you use it on localhost, set 127.0.0.1
on domains of keys