Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#18996 closed Cleanup/optimization (fixed)

better document overridden model save not called on bulk update.

Reported by: bram.dejong@… Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords: docs overriding save bulk update
Cc: tomas.ehrlich@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The documentation on overriding predefined model methods should mention that bulk updates do no trigger customized save methods. I.e. if I do MyModel.objects.all().update(a=5) will not trigger MyModel.save().

The docs do already mention this in the description of update( ) but not in the description of overriding methods:
https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods

Attachments (3)

18996-1.diff (1.4 KB ) - added by Tomáš Ehrlich 12 years ago.
Improved documentation
18996-2.diff (1.7 KB ) - added by Tomáš Ehrlich 12 years ago.
save(), pre_save and post_save are not called
18996-3.diff (1.2 KB ) - added by Tim Graham 12 years ago.
Minor tweaks to last patch

Download all attachments as: .zip

Change History (12)

comment:1 by Preston Holmes, 12 years ago

Needs documentation: set
Summary: Overriding predefined model methods vs bulk update.better document overridden model save not called on bulk update.
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

by Tomáš Ehrlich, 12 years ago

Attachment: 18996-1.diff added

Improved documentation

comment:2 by Tomáš Ehrlich, 12 years ago

Has patch: set

comment:3 by Anssi Kääriäinen, 12 years ago

Patch needs improvement: set

The patch isn't correct - you can't use pre/post_save for update operations. In addition, bulk_create would be good to mention at the same time, too. It is a bit sad that there isn't anything you can use for .update() operations currently...

by Tomáš Ehrlich, 12 years ago

Attachment: 18996-2.diff added

save(), pre_save and post_save are not called

comment:4 by Tomáš Ehrlich, 12 years ago

Cc: tomas.ehrlich@… added

by Tim Graham, 12 years ago

Attachment: 18996-3.diff added

Minor tweaks to last patch

comment:5 by Tim Graham, 12 years ago

Patch needs improvement: unset

comment:7 by Tomáš Ehrlich <tomas.ehrlich@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 443999a1eeea70e4deebcf31f8f845696be62c3d:

Fixed #18996 - Docs on overriden model methods

comment:8 by Tim Graham <timograham@…>, 12 years ago

In 5fb22329a14695419f191da8b7d0b5b22793aff0:

Merge pull request #422 from elvard/18996

Fixed #18996 - Clarified overriden model methods not called on bulk operations

comment:9 by Tim Graham <timograham@…>, 12 years ago

In d2891d1c0751d53c10f19672ac7d232b6e5088b0:

[1.4.x] Fixed #18996 - Clarified overriden model methods not called on bulk operations

Backport of 443999a1eeea70e4deebcf31f8f845696be62c3d from master.

Note: See TracTickets for help on using tickets.
Back to Top