Python Forum

Full Version: Django don't redirect to an external url
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,

I have this view where I execute a redirect to an external site:

def redpagopa(request):
   if request:
       return redirect('http://www.google.com/')
   else:
       return render_to_response('404.html')
....

call=redpagopa(urlpa) # call of the redirect function, redirect doesn't work
where urlpa is the url passed to the function redpagopa..in this code I explicited the address for example google. But the redirect doens't work. If I create an url entry in urls.py:

url(r'^redpagopa/$', 'mopa.views.redpagopa', name='redpagopa')
and in the browser I give the address: http://mysite.com/redpagopa the redirect works. I need when redirect is called, the browser be redirect on the specified url.
More information: I query a SOAP service and the response of this service is an url. So I need to redirect the browser on this url. I call with the instruction call=redpagopa(urlpa) the function to redirect Django (and the browser??) to the passed url.
There is some error in my code? I use Django v1.3.
Thanks.