ES-DOC / esdoc-questionnaire

ES-DOC Questionnaire (webform generator for creating CIM Documents). POC: @allynt
Other
2 stars 1 forks source link

Ability to add unsaved models to saved models. #481

Closed allynt closed 7 years ago

allynt commented 7 years ago

WHO: @allynt

Ability to add unsaved models to saved models.

allynt commented 7 years ago

Figured out what is going on...

When I serialize a model to JSON, I first work out if the model is unsaved or saved. If it is unsaved, I assume that I used my cleverness to overcome the default Django limitations regarding relationship fields to unsaved models. If it is saved, I assume that I should just do the standard Django things. The problem is that that latter approach results in me missing out the newly-added-but-as-yet-unsaved things.

The solution is to always combine saved and unsaved relationship fields.

allynt commented 7 years ago

c2bd0a9ff718f28ea5012f2b17625cddb8cca365 & cf46c41385deb80fab2d819a48e5c6082cc404cd make sure that the serializer correctly distinguishes between saved & unsaved instances.