Ticket #20136: 20136.diff

File 20136.diff, 1.4 KB (added by Tim Graham, 12 years ago)
  • docs/ref/django-admin.txt

    diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
    index 6277b22..48d497a 100644
    a b application, ``<dirname>/foo/bar/mydata.json`` for each directory in  
    370370:setting:`FIXTURE_DIRS`, and the literal path ``foo/bar/mydata.json``.
    371371
    372372When fixture files are processed, the data is saved to the database as is.
    373 Model defined ``save`` methods and ``pre_save`` signals are not called.
     373Model defined :meth:`~django.db.models.Model.save` methods and
     374:data:`~django.db.models.signals.pre_save` signals are not called.
     375:data:`~django.db.models.signals.post_save` signals will be called with
     376``raw=True`` since the instance only contains attributes that are local to the
     377model. You may, for example, want to disable ``post_save`` handlers that access
     378related fields that aren't present during fixture loading and would otherwise
     379raise an exception::
     380
     381    from django.db.models.signals import post_save
     382    from .models import MyModel
     383
     384    def my_handler(**kwargs):
     385        # disable the handler during fixture loading
     386        if kwargs.get('raw'):
     387            return
     388
     389        ...
     390
     391    post_save.connect(my_handler, sender=MyModel)
    374392
    375393Note that the order in which fixture files are processed is undefined. However,
    376394all fixture data is installed as a single transaction, so data in
Back to Top