kaoslabsinc / dj-kaos-utils

Set of utilities and helpers for rapid development of Django applications
https://dj-kaos-utils.readthedocs.io
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Does calling `update_or_create()` when updating inline models make sense? #5

Open gerdemb opened 1 year ago

gerdemb commented 1 year ago

Should this call to update_or_create() be replaced with update()? In the case a lookup_value is passed but doesn't exist, a create will be triggered, which I don't think is what we want. I think our "rule" is that the existence of a lookup_field means update and that the absence of a lookup_field means create. To follow this rule, I think that means we should never call any "or" functions like get_or_create or update_or_create. Right?

https://github.com/kaoslabsinc/dj-kaos-utils/blob/617aca24ccf5cfed35a1e9864a42c401336d7534/dj_kaos_utils/rest/serializers.py#L107-L126

gerdemb commented 1 year ago

I think this issue doesn't apply any more with new WritabledNestedSerializer.