简体   繁体   中英

how can I pass locally stored form data to django view and save it on the database

How can I pass form data from an offline website to django view which than will save it on the database.

Filled in form > save form > saves in local storage > when connected to internet > upload the data to database

Is there a guide on how to do this or can someone help?

First of all, you will need some api (like django-rest-framework to provide some way to comunicate from your local - offline website to global - online website. Using normal django views wouldn't be efficient for that.

Next - you need some way to check if connection can be estabilished - and run that check for example in 5 minute intervals (using cron propably, or some external process because django won't handle that by itself). You can also trigger that check by hand.

Next - when connection can be estabilished, you need to connect to API and push all changes from your local database to global website. After each change, you should mark it in local database that it is already synchronized or just remove it from queue.

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