Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django redirect to `tel` url yields `SuspiciousOperation`

I'm writing a little website that logs when users click on a link (which is obviously a telephone number). It does this through a view, which then redirects to that telephone number.

Naturally, (I agree this should be default behavior) Django sees that as a SuspiciousOperation. In my case, I'm doing it intentionally. How can I suppress this error and let the view resolve like I want it to?

like image 953
Thane Brimhall Avatar asked Jan 14 '23 11:01

Thane Brimhall


1 Answers

I had cannot import name HttpResponseRedirectBase error with the first answer. I managed to do (nearly) as expected with :

from django.http.response import HttpResponseRedirectBase
HttpResponseRedirectBase.allowed_schemes += ['tel']
like image 81
mansuetus Avatar answered Jan 16 '23 19:01

mansuetus