Redirect on POST

21 views
Skip to first unread message

Mark Davies Tan

unread,
Jun 7, 2019, 7:30:38 AM6/7/19
to Django users
Hi all,

I have this scenario. I have a client who wants to call a POST API of mine which then redirects to my site. So client has his own site which has a button that does a POST to my registration API to register a user onto my site and should automatically redirect to my site without the client needing to do anything other than call my API. The client isn't willing to place a code like window.location upon getting a response from the POST call. So the redirecting has to be done by my django API. I've tried returning a HTTPResponseRedirect when the POST is called but nothing happens. Since I don't have access to my client's code, I've been testing it out on w3schools and jsfiddle. Any clues on this?

Thanks,
Mark

Aldian Fazrihady

unread,
Jun 7, 2019, 7:54:28 AM6/7/19
to django...@googlegroups.com
How does your client call your POST API? Via AJAX (assuming, CORS header properly set), or via action attribute of the form?
If it is called via action attribute, then there should be no problem with HTTPResponseRedirect. You probably need a bug fixing.
If it is called via Ajax, then, IMO, there is no way other than setting JS window.location.

Regards,

Aldian Fazrihady.

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/77af30ce-2adc-49c9-b7b5-1f7e65318694%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages