开发者

Validate Django form that POSTS to an external site

Curious about how developers more experienced with Django than I might handle this: I want to build some Django forms that will be posting to a site external to my own, but I also want to retain the built-in form validation. Of course, Django forms typically validate by posting back to their own view and re-rendering if anything went wrong, or redirecting to the "landing page" if the validation succeeds. In this case, though, since the landing page is a different site entirely I would lose my POST data in the redirect.

My initial thoughts on the matter are to try and pass everything along as GET parameters, though it's not my favorite idea since there are limitations there that I may run up against (file uploads, for example). Another idea is that I could send off an AJAX request to my validating view first and manually handle the validation errors that come back or allow the POST directly if it's clean, but that feels quite messy when 开发者_StackOverflowcompared to the default validation flow.

It feels like this is something that would have been considered when building the Django forms system, but that may just be wishful thinking on my part.


Use an iframe to preserve the validation workflow.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜