We have a view which redirects to a Non-HTTP url scheme. Its used in an iOS app. But since we have upgraded to Django1.4 we are getting a crash when this redirect code is executed. It crashes with
SuspeciousOperation at /myyrlscheme/
Unsafe redirect to URL with scheme appdev:
Following is the code:
if acode and acode.has_key('access_token'):
if DOMAIN == 'dev.mywebsite.com':
return HttpResponseRedirect('appdev://fbconnect?token=%s'%(acode['access_token']))
else:
return HttpResponseRedirect('app://fbconnect?token=%s'%(acode['access_token']))
I can understand why this crashes as HttpResponseRedirect
expects a HTTP(s)
url scheme. How do I tell Django that this is a safe url and just blindly redirect?
I believe you'll need to have a custom Response object, consider following:
response = HttpResponse("", status=302)
response['Location'] = "appdev://..."
return response
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With