Search code examples
djangodjango-views

Passing a variable in redirect in Django


I'm trying to pass a variable using the redirect function, but it is returning none.

def one:
    # define location variable here
    return redirect(getting_started_info, location=location)

def getting_started_info(request, location=''):
    location = location
    ...

Why is the variable in the redirect not passing?


Solution

  • return HttpResponseRedirect(reverse('getting_started_info', kwargs={'location': location}))