Get id_token for send to the URL logout keycloak

Hello, I am generating an application with django-allauth == 0.61.1 and Keycloak 22 In this version of keycloak you must send two parameters: post_logout_redirect_uri and id_token_hint to send to the logout endpoint and perform this process both in the application and in keycloak, but I don’t know how to get the id_token to send to the endpoint. This way I have been implementing it but it does not get the id_token:

def logout_view(request):

    id_token = request.session.get('id_token')


    post_logout_redirect_uri = 'http://app.com/'


    params = {
        'client_id': 'client_id_de_keycloak',  
        'post_logout_redirect_uri': post_logout_redirect_uri,
    }


    if id_token:
        params['id_token_hint'] = id_token


    logout_url = f"https://auth.apps.openshift.daytwo.cloud/realms/sercop/protocol/openid-connect/logout?{urlencode(params)}"


    request.session.flush()
return redirect(logout_url)

1.- What is the correct way to get the id_token ?
2.- Has anyone had a similar problem ?