Django recaptcha | Install django captcha | Django recaptcha v3
Coding Python

Django reCaptcha v3 – Install reCaptcha in Django site

Django Recaptcha v3 will be installed in your django website soon, just follow my instructions. We will be using google recaptcha version 3 ( I am not a robot ) and a python library django-recaptcha for this task.

How to install, deploy or integrate django recaptcha v3?

Django recaptcha v3 installation

First, install django-recaptcha in your virtual workspace.

Visit GitHub Repo of this task/project to get all the source codes.

Install and configure django-recaptcha lib

pip install django-recaptcha

Now, add captcha in the INSTALLED_APPS section in your


Must be similar to this:

    'captcha', # add this code

    "your_app_name", # app name

Also check, Selenium Python tutorial for beginners

Recaptcha keys configuration

Add RECAPTCHA_PUBLIC_KEY and RECAPTCHA_PRIVATE_KEY at the last lines of your

RECAPTCHA_PUBLIC_KEY = 'MyRecaptchaKey123'
RECAPTCHA_PRIVATE_KEY = 'MyRecaptchaPrivateKey456'


Now, go to Google reCAPTCHA admin panel and register your site for reCAPTCHA and use those data in the upper code.

Cpatcha Form configuration

Now, create a file named and inside it you need to write the following Python codes:

from django import forms
from captcha.fields import ReCaptchaField

class FormWithCaptcha(forms.Form):
    captcha = ReCaptchaField()

Django views configuration

Write a context with "captcha" variable name that with render the form we have coded in FormWithCaptcha which is inside the .

from django.shortcuts import render
from .my_captcha import FormWithCaptcha
# Create your views here.
def home(request):
    context = {
        "captcha": FormWithCaptcha,
    return render(request, "home.html", context)

Rendering recaptcha v3

Now, we are rendering recaptcha using the Jinja template method. Use {{captcha}} for rendering the captcha form.

For now, have a look here:

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


Getting data from recaptcha form

To get data from django recaptcha, you need to use g-recaptcha-response.

get_recaptcha = request.POST.get("g-recaptcha-response")

This will return true if the checkbox is checked, else false.

5 3 votes
Article Rating
Notify of
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Juan Manuel

This will return a string with 484 characters it will not return a True statement

Coder bro

Thanks brother! A lot helpful. May be this is the most easiest way to integrate django recaptch version 3 in my site.

Arda Gurman

after I’ve submitted the form and go back and refresh page what will happen if this text comes again. i am trying to find a solution in django no hope redirect is not useful.

Would love your thoughts, please comment.x