Changes between Initial Version and Version 1 of Ticket #30053
- Timestamp:
- Dec 21, 2018, 8:39:23 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #30053 – Description
initial v1 1 {{{QuerySet.update_or_create()}}} is great since it lifts the burden of thread-safety and repeated code from the client. However there exists some scenarios where the "update" logic should be hidden behind a condition. (E.g. only update if the value of a {{{DateTimeField}}} is less than some value). There isn't much help for clients in these scenarios, with the best solution being to copy+paste {{{QuerySet.update_or_create()}}} and add a condition to the {{{if created:}}} expression.1 {{{QuerySet.update_or_create()}}} is great since it lifts the burden of thread-safety and repeated code from the client. However there exists some scenarios where the "update" logic should be hidden behind a condition. (E.g. only update if the value of a {{{DateTimeField}}} is less than some value). There isn't much help for clients in these scenarios, with the best solution being to copy+paste {{{QuerySet.update_or_create()}}} and add a condition to the {{{if created:}}} expression. 2 2 3 3 The condition would most likely be a callable that accepts one argument, the {{{got}}}ten instance.