summaryrefslogtreecommitdiff
path: root/docs/orms.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/orms.rst')
-rw-r--r--docs/orms.rst32
1 files changed, 28 insertions, 4 deletions
diff --git a/docs/orms.rst b/docs/orms.rst
index 8e5b6f6..9cf7f8e 100644
--- a/docs/orms.rst
+++ b/docs/orms.rst
@@ -11,6 +11,8 @@ adding dedicated features.
Django
------
+.. currentmodule:: factory.django
+
The first versions of factory_boy were designed specifically for Django,
but the library has now evolved to be framework-independant.
@@ -24,14 +26,14 @@ All factories for a Django :class:`~django.db.models.Model` should use the
:class:`DjangoModelFactory` base class.
-.. class:: DjangoModelFactory(Factory)
+.. class:: DjangoModelFactory(factory.Factory)
Dedicated class for Django :class:`~django.db.models.Model` factories.
This class provides the following features:
- * :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
+ * :func:`~factory.Factory.create()` uses :meth:`Model.objects.create() <django.db.models.query.QuerySet.create>`
+ * :func:`~factory.Factory._setup_next_sequence()` selects the next unused primary key value
* 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.
@@ -44,7 +46,7 @@ All factories for a Django :class:`~django.db.models.Model` should use the
.. code-block:: python
- class UserFactory(factory.DjangoModelFactory):
+ class UserFactory(factory.django.DjangoModelFactory):
FACTORY_FOR = models.User
FACTORY_DJANGO_GET_OR_CREATE = ('username',)
@@ -68,3 +70,25 @@ All factories for a Django :class:`~django.db.models.Model` should use the
<User: jack>
>>> User.objects.all()
[<User: john>, <User: jack>]
+
+
+Mogo
+----
+
+.. currentmodule:: factory.mogo
+
+factory_boy supports `Mogo`_-style models, through the :class:`MogoFactory` class.
+
+`Mogo`_ is a wrapper around the ``pymongo`` library for MongoDB.
+
+.. _Mogo: https://github.com/joshmarshall/mogo
+
+.. class:: MogoFactory(factory.Factory)
+
+ Dedicated class for `Mogo`_ models.
+
+ This class provides the following features:
+
+ * :func:`~factory.Factory.build()` calls a model's ``new()`` method
+ * :func:`~factory.Factory.create()` builds an instance through ``new()`` then
+ saves it.