Support updating many fields on CounterField.
Review Request #5279 — Created Jan. 20, 2014 and submitted
This adds two new class methods for
CounterField
:increment_many
, and
decrement_many
. These can be used for incrementing or decrementing many
fields at once on an instance of a model.It also makes two changes to saving field values.
An initializer can now return
None
, meaning thatCounterField
won't set
the field and save the object. That's intended for when an initializer
will be handling setting the field itself, perhaps through
increment_many()
orupdate()
.When saving the field,
CounterField
now passesupdate_fields
tosave()
,
ensuring we only save those affected fields and don't unintentionally
save other aspects of the model.
Tested along with a change on Review Board that makes extensive use
of these functions.