I think you should try the @Selcuk suggestion: return a template from FormView with HTML code similar to:
<html>
<head>
<meta http-equiv="refresh" content="0;URL={{ url }}" />
</head>
<body>
Waiting message
</body>
</html>
So your django view will become:
from urllib import quote
from django.shortcuts import render
class UserPhoneNumberView(FormView):
form_class = UserPhoneNumberForm
template_name = "get_user_phonenumber.html"
def form_valid(self, form):
phonenumber = self.request.POST.get("mobile_number")
unique = self.request.POST.get("unique")
url = "http://example.com/"+unique
body = quote("See this url: "+url)
nonhttp_url = "sms:"+phonenumber+"?body="+body
context = {'url': nonhttp_url}
return render(request, 'theTemplate.html', context)
I just tried on my phone, and redirected it to my SMS application.
source
share