Django role based access controle using Keycloak

Hello everyone, I’m trying to manage access to my web app using RBAC
1- In keycloak I created manager role and I give it to the user
2- the authentication succeeded and I can get the user info like the email
the problem : I don’t know how to get the user role I tried the following code:

from django.shortcuts import render
from .models import Info
from django.contrib.auth.decorators import login_required, user_passes_test
from django.urls import reverse_lazy

# Create your views here.

def is_manager(request):
    roles = request.user.oidc_profile['realm_access']['roles']

    # Check if the user has the 'manager' role
    if 'Manager' in roles:
        print("Not a manager")

but I got this error:
‘User’ object has no attribute ‘oidc_profile’

Hi, soso
I suggest you take a look at this my article in below link .