summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-04 23:18:02 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-04 23:18:02 +0100
commit7d792430e103984a91c102c33da79be2426bc632 (patch)
tree0044c449e933e93d4fecf1e80e6b361c6c3e8150 /docs
parent9422cf12516143650f1014f34f996260c00d4c0a (diff)
downloadfactory-boy-7d792430e103984a91c102c33da79be2426bc632.tar
factory-boy-7d792430e103984a91c102c33da79be2426bc632.tar.gz
Add a 'after post_generation' hook to Factory.
Use it in DjangoModelFactory to save objects again if a post_generation hook ran. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'docs')
-rw-r--r--docs/orms.rst5
-rw-r--r--docs/reference.rst13
2 files changed, 16 insertions, 2 deletions
diff --git a/docs/orms.rst b/docs/orms.rst
index eae31d9..d6ff3c3 100644
--- a/docs/orms.rst
+++ b/docs/orms.rst
@@ -32,5 +32,6 @@ All factories for a Django :class:`~django.db.models.Model` should use the
* :func:`~Factory.create()` uses :meth:`Model.objects.create() <django.db.models.query.QuerySet.create>`
* :func:`~Factory._setup_next_sequence()` selects the next unused primary key value
- * When using :class:`~factory.RelatedFactory` attributes, the base object will be
- :meth:`saved <django.db.models.Model.save>` once all post-generation hooks have run.
+ * When using :class:`~factory.RelatedFactory` or :class:`~factory.PostGeneration`
+ attributes, the base object will be :meth:`saved <django.db.models.Model.save>`
+ once all post-generation hooks have run.
diff --git a/docs/reference.rst b/docs/reference.rst
index e2246aa..d100b40 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -189,6 +189,19 @@ The :class:`Factory` class
.. OHAI_VIM*
+ .. classmethod:: _after_postgeneration(cls, obj, create, results=None)
+
+ :arg object obj: The object just generated
+ :arg bool create: Whether the object was 'built' or 'created'
+ :arg dict results: Map of post-generation declaration name to call
+ result
+
+ The :meth:`_after_postgeneration` is called once post-generation
+ declarations have been handled.
+
+ Its arguments allow to handle specifically some post-generation return
+ values, for instance.
+
.. _strategies: