FormSG | Form builder for the Singapore Government
kandi X-RAY | FormSG Summary
kandi X-RAY | FormSG Summary
Form builder for the Singapore Government
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of FormSG
FormSG Key Features
FormSG Examples and Code Snippets
Community Discussions
Trending Discussions on FormSG
QUESTION
I have 2 models in 1 form. in this form data can be changed. For 1 model (Sloep_core) the content only have to update, this is working. for the other model (Sloep_gegevens) the content normaly will update. Only if the value 'sloepnaam' changed in the form for model 'Sloep_gegevens', the record for the model 'Sloep_gegevens' must enter a new record and not update the old one. The save() must change from update to insert, but how??
I have tried to put soms code together (with some search actions). I come to the code below but now it is always a insert the code. Is someone have a idea to get it right?
model.py:
...ANSWER
Answered 2017-May-17 at 11:42I found the answer for my problem. In the view I didn't give a pk with the SloepGegevensForm in the POST request.model.
I changed: formSG = SloepGegevensForm(request.POST)
into formSG = SloepGegevensForm(request.POST, instance=sloep_sg)
This makes the save() working.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install FormSG
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page