Code

Ticket #18996: 18996-2.diff

File 18996-2.diff, 1.7 KB (added by Elvard, 22 months ago)

save(), pre_save and post_save are not called

Line 
1diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
2index d17d869..5e97fc1 100644
3--- a/docs/ref/models/querysets.txt
4+++ b/docs/ref/models/querysets.txt
5@@ -1359,6 +1359,8 @@ has a side effect on your data. For more, see `Safe methods`_ in the HTTP spec.
6 
7 .. _Safe methods: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.1
8 
9+.. _ref-models-querysets-bulk-create:
10+
11 bulk_create
12 ~~~~~~~~~~~
13 
14diff --git a/docs/topics/db/models.txt b/docs/topics/db/models.txt
15index f29cc28..9dcc90e 100644
16--- a/docs/topics/db/models.txt
17+++ b/docs/topics/db/models.txt
18@@ -762,13 +762,20 @@ built-in model methods, adding new arguments. If you use ``*args,
19 **kwargs`` in your method definitions, you are guaranteed that your
20 code will automatically support those arguments when they are added.
21 
22-.. admonition:: Overriding Delete
23+.. admonition:: Overridden model methods are not called on bulk operations
24 
25     Note that the :meth:`~Model.delete()` method for an object is not
26     necessarily called when :ref:`deleting objects in bulk using a
27     QuerySet<topics-db-queries-delete>`. To ensure customized delete logic
28     gets executed, you can use :data:`~django.db.models.signals.pre_delete`
29     and/or :data:`~django.db.models.signals.post_delete` signals.
30+   
31+    Unfortunatelly there's no workaround while
32+    :ref:`creating<ref-models-querysets-bulk-create>` or
33+    :ref:`updating<topics-db-queries-update>` objects in bulk using Queryset,
34+    since neither of :meth:`~Model.save()`,
35+    :data:`~django.db.models.signals.pre_save` and
36+    :data:`~django.db.models.signals.post_save` is called.
37 
38 Executing custom SQL
39 --------------------