Ticket #20136: 20136.diff

File 20136.diff, 1.4 KB (added by timo, 16 months ago)
1diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
2index 6277b22..48d497a 100644
3--- a/docs/ref/django-admin.txt
4+++ b/docs/ref/django-admin.txt
5@@ -370,7 +370,25 @@ application,  ``<dirname>/foo/bar/mydata.json`` for each directory in
6 :setting:`FIXTURE_DIRS`, and the literal path ``foo/bar/mydata.json``.
8 When fixture files are processed, the data is saved to the database as is.
9-Model defined ``save`` methods and ``pre_save`` signals are not called.
10+Model defined :meth:`` methods and
11+:data:`~django.db.models.signals.pre_save` signals are not called.
12+:data:`~django.db.models.signals.post_save` signals will be called with
13+``raw=True`` since the instance only contains attributes that are local to the
14+model. You may, for example, want to disable ``post_save`` handlers that access
15+related fields that aren't present during fixture loading and would otherwise
16+raise an exception::
18+    from django.db.models.signals import post_save
19+    from .models import MyModel
21+    def my_handler(**kwargs):
22+        # disable the handler during fixture loading
23+        if kwargs.get('raw'):
24+            return
26+        ...
28+    post_save.connect(my_handler, sender=MyModel)
30 Note that the order in which fixture files are processed is undefined. However,
31 all fixture data is installed as a single transaction, so data in