title: User Registration after mobile verification
body: <p>I want the user to submit the registration form and then redirect to another page to verify the number he entered in the mobile number field. If the verification is successful, my user should be created otherwise an error.</p>
  
  <p>Currently my Register View looks like this:</p>
  
  <pre><code>def register_view(request):
      template = "accounts/register.html"
      print(request.user.is_authenticated())
      next = request.GET.get('next')
      print next
      title = "Register"
  
      form = UserRegisterForm(request.POST or None,)
  
      if form.is_valid():
          user = form.save(commit=False)
       #    number = user.mobile_number
       #    to_check = phonenumbers.parse(number,"TR")
       #    if phonenumbers.is_possible_number(to_check) and phonenumbers.is_valid_number(to_check):
  
          #   formatted_number = phonenumbers.format_number(to_check, phonenumbers.PhoneNumberFormat.E164)
          #   params = {
          #       'api_key': ' api-key',
          #       'api_secret': 'api-secret',
          #       'number': formatted_number,
          #       'brand': 'MobileVerification',
          #   }
          #   url = 'https://api.nexmo.com/verify/json?' + urllib.urlencode(params)
          #   response = urllib.urlopen(url)
          #   resp_dict = json.loads(response.read())
          #   request.session["user_request_id"] = resp_dict['request_id']
          #   messages.success(request,"A 4 digit pin has been successfully sent to your number.")
          #   return HttpResponseRedirect(reverse('pin_verify'))
          # else:
          #   messages.error(request,"Enter a valid mobile number.")
  
  
          # params2 = {
  
          # }
          # url = 'https://api.nexmo.com/verify/search/json?' + urllib.urlencode(params)
  
  
          password = form.cleaned_data.get('password')
          user.set_password(password)
          user.save()
          new_user = authenticate(username=user.mobile_number, password=password)
          login(request, new_user)
          if next:
              return redirect(next)
          return redirect("/")
  
      context = {
          "form": form,
          "title": title
      }
      return render(request, template, context)
  </code></pre>
  
  <p>The commented code in the view is what I tried by getting the number and then redirecting but this is not how it should be.</p>
  
  <p>My Register template looks like this:</p>
  
  <pre><code>{% extends "base.html" %}
  {% load i18n %}
  {% load crispy_forms_tags %}
  
  
  {% block content %}
  &lt;div class='row'&gt;
  &lt;div class='col-sm-6 col-sm-offset-3'&gt;
  &lt;h1&gt;Register for free!&lt;/h1&gt;
  &lt;form method="post" action="."&gt; 
  
    {% csrf_token %}
    {{ form|crispy }}
  
    &lt;input class='btn btn-block btn-primary' type="submit" value="{% trans 'Join' %}" /&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;hr/&gt;
  &lt;div class='row'&gt;
  &lt;div class='col-sm-6 col-sm-offset-3 text-align-center'&gt;
  &lt;p&gt;Need to &lt;a href="{% url 'login' %}"&gt;Login&lt;/a&gt;?&lt;/p&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  
  {% endblock %}
  </code></pre>