Django redirects to user url

From my Django application, how do I redirect the user to somescheme: //someurl.com?

To give you some context if it helps, I have a working oauth2 server written in Python / Django and I need to allow users to register redirect_uris that have a custom URL scheme. This custom URL scheme is used to handle redirects in native applications .

My first reaction was to use an HttpResponseRedirect, but this URL has a user scheme and is not HTTP, so I assume this is not what I want. Thanks in advance for any advice you can give.

Edit: I tried this and Django correctly returned the response without throwing an error, but the browser does not redirect this URL. I use Chrome to verify this.

Edit 2: HttpResponseRedirect works fine on safari.

+5
source share
2 answers

class HttpResponseRedirect

The first argument to the constructor is required - the path to the redirect. This can be a full URL (for example, "http://www.yahoo.com/search/") or an absolute path without a domain> (for example, '/ search /'). See HttpResponse for other optional constructor arguments. Note that this returns an HTTP status code of 302.

This is from here: https://docs.djangoproject.com/en/dev/ref/request-response/

It should work anyway from what I'm reading.

+4

, Django http, https ftp :

https://www.djangoproject.com/weblog/2012/jul/30/security-releases-issued/

OAuth .
Django ( Apache) 500 (django.core.exceptions.SuspiciousOperation) . HttpResponseRedirect :

location = < your redirect URL >
res = HttpResponse(location, status=302)
res['Location'] = location
return res
+16

All Articles