summaryrefslogtreecommitdiff
path: root/docs/orms.rst
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-09-25 10:58:12 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-09-25 10:58:12 +0200
commit2e5046bda818771f474a1514465f71bd62be9dcd (patch)
treeade9d0c6f02fbc4dfbe066b41c6765c215a68f81 /docs/orms.rst
parentea00fa30273c7355c02a361c1193ea4764528edb (diff)
downloadfactory-boy-2e5046bda818771f474a1514465f71bd62be9dcd.tar
factory-boy-2e5046bda818771f474a1514465f71bd62be9dcd.tar.gz
Fix Django sequences with abstract base models.
Diffstat (limited to 'docs/orms.rst')
-rw-r--r--docs/orms.rst15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/orms.rst b/docs/orms.rst
index a463bfb..33b3e0a 100644
--- a/docs/orms.rst
+++ b/docs/orms.rst
@@ -74,6 +74,21 @@ All factories for a Django :class:`~django.db.models.Model` should use the
[<User: john>, <User: jack>]
+.. note:: If a :class:`DjangoModelFactory` relates to an :obj:`~django.db.models.Options.abstract`
+ model, be sure to declare the :class:`DjangoModelFactory` as abstract:
+
+ .. code-block:: python
+
+ class MyAbstractModelFactory(factory.django.DjangoModelFactory):
+ FACTORY_FOR = models.MyAbstractModel
+ ABSTRACT_FACTORY = True
+
+ class MyConcreteModelFactory(MyAbstractModel):
+ FACTORY_FOR = models.MyConcreteModel
+
+ Otherwise, factory_boy will try to get the 'next PK' counter from the abstract model.
+
+
.. class:: FileField
Custom declarations for :class:`django.db.models.FileField`