'WSGIRequest' object cannot be interpreted as an integer

So, I’m creating a project were I send a verification code to the user confirm its email

the view for this is:


def generateVerificationCode(length):
    characters = string.ascii_letters + string.digits
    return ''.join(secrets.choice(characters) for i in range(length))

I’m creating the object right here:

@csrf_exempt
def createuser(request):
    form = MyUserCreationForm()

    if request.method == 'POST':
        form = MyUserCreationForm(request.POST)
        if form.is_valid():     
            user = form.save(commit=False)
            user.is_active=False
            user.save()

            verification_code = generateVerificationCode(6) <<<<< RIGHT HERE
            request.session['verification_code'] = verification_code
            

            activateEmail(request,user,form.cleaned_data.get('email'))
            activeThroughCode(request)
            return redirect('activate')
        else:
            messages.error(request,'CREATE A VALID USER')
    context = {'form':form}
    return render(request, 'signup.html', context)

the view where I’m accessing this view is:

def activeThroughCode(request,):
    if request.method == 'POST':
        form = VerificationForm(request.POST)
        if form.is_valid:
            entered_code = request.POST.get('verification_code')

            storaged_code = request.session.get('verification_code')
            

            if entered_code == storaged_code:
                username = request.session.get('username')  
                user = User.objects.get(username=username)

                user.is_active = True
                
                
                user.save()
                messages.success(request, f'Your account is active with success.')
                return redirect('login')
            else:
                messages.error(request, f"It wasn't possible to confirm your email")

    return render(request, 'activate.html')

the email actually was send, with the length I wanted, but the error in

return ''.join(secrets.choice(characters) for i in range(length))

in specific in range(length). I dont know what’s a WSGI so I also don’t know how to solve

also, the

First, it looks like your message was truncated - was there more information to share?

When requesting help with an error, please post the complete error message with the traceback. (Surrounded between lines of ```, like the other code fragments posted.)