Redirect to external url with parameters in django

1,901 views
Skip to first unread message

Hossein Rashnoo

unread,
Jan 27, 2015, 2:30:05 AM1/27/15
to django...@googlegroups.com
I want when a user do something in my view then i redirect him to another website with some parameters as POST method Like when you submit a form.
I think its may be something like this:

    return HttpResponseRedirect("url","parameters")

How can i do that?

Stephen J. Butler

unread,
Jan 27, 2015, 2:39:48 AM1/27/15
to django...@googlegroups.com
Use django.utils urlencode.

return HttpResponseRedirect(base_url + '?' + urlencode(params))

Note that a redirect is always turned into a GET request, never a
POST. If you really need POST you'll have to construct a page with the
proper form elements, and then either have the user submit it (no-js)
or post it using JavaScript yourself.
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6650db6b-1bd9-4f70-bbee-ed6bca3b95c2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages