#25363: Model fields pre_save not called if force_insert=True -------------------------------------+------------------------------------- Reporter: davidfischer-ch | Owner: | davidfischer-ch Type: Bug | Status: assigned Component: Database layer | Version: 1.8 (models, ORM) | Severity: Normal | Resolution: Keywords: pre_save,save | Triage Stage: | Unreviewed Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by davidfischer-ch):
* has_patch: 0 => 1 Comment: I just wrote a test, and discovered the pre_save method is always called, but in two different places depending if its an INSERT or an UPDATE. INSERT: in SqlInsertCompiler and UPDATE: in Model._save_table. https://github.com/django/django/blob/stable/1.8.x/django/db/models/sql/compiler.py#L927 https://github.com/django/django/blob/stable/1.8.x/django/db/models/base.py#L823 Please, can anyone explain me why? Also, unfortunately the fact that pre_save is called lately during the save defeat the implementation of a clean mix-in to track updated fields and make UPDATE queries lighter. But that's another story. -- Ticket URL: <https://code.djangoproject.com/ticket/25363#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/073.20f16d5ef0cfd3b015d31d99d68c4070%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.