0

I am in my views.py and I need to go to a url with post request along with post data.

I tried HttpResponseRedirect but it does not take post data as param.

class WebPaymentView(FormView):

    template_name = "payment/payment.html"
    form_class = NameForm

    def form_valid(self, form):
        # code
        return HttpResponseRedirect(url, data=data, content_type="application/x-www-form-urlencoded")

Last line gives error:

TypeError: __init __() got an unexpected keyword argument 'data'

I want to post to this url as well as redirect to it. Any idea how?

Kishan Mehta
  • 2,598
  • 5
  • 39
  • 61
  • Any alternative to this ? I am now using ajax call but django rest framework api url I need to call needs user auth token. P.S Newbie in Jquery/Ajax – Kishan Mehta Aug 30 '16 at 13:33

1 Answers1

1

The server side cannot redirect the user and make it a post request. Based on the simple code shared, what I think you are looking for is the action attribute of the Form html tag.

Swakeert Jain
  • 776
  • 5
  • 16