简体   繁体   中英

How to post a form to django site, securely and from another site

I have a django app which need to receive post requests from another site using html+javascript. For example i have mydjangosite.com and smallhtmlsite.com What i want is : user visit smallhtmlsite.com and fill a form, then he pushing submit button and mydjangosite.com receive request and create objects(form saving models actually). So i will have a view which will handle this requests. But how can these been done securely?

I have a django app which need to receive post requests from another site using html+javascript.

You don't have to ! You can build an API instead ;)

You create an API call - small site calls the API of main site . In that situation, the form is handled by a view in small site and the API is called via the server. Check out Django REST Framework.

Note: That solution wouldn't stop you from using AJAX but it would avoid cross domain issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM