Error in using the passed data from redirect into the function we are redirecting to the new view in Django App?

I am passing a variable using redirect in Django but when I am trying to print the variable into another view using request.GET it is showing as - <QueryDict: {}> in request.GET which means there is no dictionary passed - Here is my code -

def add_prompt(request):

    email='abc@gmail.com'

    return redirect('/content/',{'email_id':email})

Here is the code for the content function -

def content(request):

    print(request.GET)

    return render(request,'abd/content.html')

Output on the console -

<QueryDict: {}>

If I use request.GET.get('email_id') -

Output -

None

if you want to pass GET parameter, is would be done via url. so it should be something like this :

def add_prompt(request):

    email='abc@gmail.com'

    return redirect(f'/content/?email_id={email}')
Back to Top