External django redirect with POST parameters

前端 未结 3 1738
抹茶落季
抹茶落季 2020-12-08 21:36

I\'m trying to create a redirect in a Django view to an external url with some get parameters attached to the request. After doing some looking around and some trying around

3条回答
  •  醉梦人生
    2020-12-08 22:11

    I suggest the following approach. In your Django view/template return form to the browser with all the parameters that you want to post as hidden form elements. As soon as the form loads the JavaScript will submit (POST) form to where ever you want.

    View:

    from django.shortcuts import render_to_response
    
    def view(request):
        return render_to_response('test.html', { 'foo': 123, 'bar': 456 })
    

    Template:

    
    
        test
         
    
    
    

提交回复
热议问题