Changes between Initial Version and Version 1 of Ticket #30053


Ignore:
Timestamp:
Dec 21, 2018, 8:39:23 AM (5 years ago)
Author:
Joshua Cannon
Comment:

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 somevalue). 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.
    22
    33The condition would most likely be a callable that accepts one argument, the {{{got}}}ten instance.
Back to Top