Django: Saving automated JSON POST from software (no user form!) in several tables (models)

Needed to save POST data in several tables\models in 2 apps (one - only 4 POST receiving) , depending on POST content. One model - ActionFeed will be JSON field and save all input, others - conditionally, looking on various JSON POST values

Input data is looking like { "timestamp":"2025-04-29T07:15:12Z", "event":"MissionAccepted", ... }

#schematically 

json_data = json.loads(post_input)
Save2ActionFeed (post_inpt)  

if event=="MissionAccepted" 
#get neeses fields from json data
save2Missionsions (field1, ... , field N)  

if event=="FSDJump"
#get neeses fields from json data
save2Location(field1, ... , field M)  

etc.

Needed a sample of save2... methods, please, remember, than no forms, UI, etc - only clean POST

Вернуться на верх