title: Django: How to render a specific HTML with context in an On Approve Ajax
body: <p>In my Project after a Payment is made via PayPal I am trying to redirect it to an HTML page with certain context as per the following views:</p>
  <pre><code>def payment_complete(request):
      body = json.loads(request.body)
      order = Order.objects.get(
          user=request.user, ordered=False, id=body['orderID'])
      payment = Payment(
          user=request.user,
          stripe_charge_id=body['payID'],
          amount=order.grand_total()
      )
      payment.save()
  
      order.payment = payment
      order.ordered = True
      order.ref_code = create_ref_code()
      order.save()
      messages.success(request, &quot;Your Order was Successful ! &quot;)
      return render(request, &quot;order_completed.html&quot;, {'order': order})  &lt;------------------------
  </code></pre>
  <p>I have tried adding but it took me the home while I am trying to go to an HTML that is created to show executed payment details</p>
  <pre><code>                // similar behavior as an HTTP redirect
                  window.location.replace(&quot;/&quot;);
  </code></pre>
  <p>Also, I tried but it didn't work</p>
  <pre><code>window.location.href = 'core:payment-complete';
  </code></pre>
  <p>Here is the full paypal on approve script</p>
  <pre><code>        onApprove: function(data, actions) {
              return actions.order.capture().then(function(details) {
                  console.log(details);
                  sendData();
                  function sendData() {
                    fetch(url, {
                      method: &quot;POST&quot;,
                      headers: {
                        &quot;Content-type&quot;: &quot;application/json&quot;,
                        &quot;X-CSRFToken&quot;: csrftoken,
                      },
                      body: JSON.stringify({ orderID: orderID, payID: details.id }),
                    });
                  }
                  // Show a success message to the buyer
                  alert('Transaction completed by ' + details.payer.name.given_name + '!');
                  // similar behavior as an HTTP redirect
                  window.location.replace(&quot;/&quot;);
                  window.location.href = 'payment-complete';
              });
          }
  
  
      }).render('#paypal-button-container');
    &lt;/script&gt;
  </code></pre>