How to redirect to another domain url with post data

I have a single page application. First, the user submits JSON data ( amount

and user

) to the Django backend url ( ) API Buy view

. The view then gets the count and user data to create a hashed var. Finally, I want to redirect to a different domain url that accepts the above data.

def Buy(request):
    key = 'some_key'
    txnid = 'some_id'
    amount = reques.data.get("amount")
    firstname = request.user.firstname
    surl = 'http://mysite.in/buy/success'
    furl = 'http://mysite.in/buy/fail'
    hash = ''
    salt = 'some_salt'
    hash_list = [key, txnid, str(amount), firstname, salt]
    hash_seq = "|".join(hash_list)
    hashed = hashlib.sha512(hash_seq)
    hashed_hexdigest_lower = hashed.hexdigest().lower()
    data = {
        "key": key,
        "txnid": txnid,
        "amount": amount,
        "firstname": firstname,
        "surl": surl,
        "furl": furl,
        "HASH": hashed_hexdigest_lower
    }
    url = "https://test.site.in/payment"
    return redirect(url, kwargs=data)

      

Basically, when a redirect happens, I want to post the above data to that url, like a form. How do I do this in Django?

+3


source to share


1 answer


If it's a SPA, you save the data to localStorage

or sessionStorage

and access the new view after referral.

old view before redirection,

localStorage.setItem('myData',data);

      



new view after redirection,

var data = localStorage.getItem('myData');
localStorage.removeItem('myData');

      

0


source







All Articles