diff options
author | Raphaël Barrois <raphael.barrois@polyconseil.fr> | 2015-03-27 16:27:05 +0100 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polyconseil.fr> | 2015-03-27 16:27:05 +0100 |
commit | bdc1b815cfdf3028379c6c3f18c9c47ee8298a70 (patch) | |
tree | a15ef5f62f091aa3a06d41a9a7bd40129f921aae /tests/djapp | |
parent | 03ca4ecebc914f2e120e902b8fcbe2b526460ee6 (diff) | |
download | factory-boy-bdc1b815cfdf3028379c6c3f18c9c47ee8298a70.tar factory-boy-bdc1b815cfdf3028379c6c3f18c9c47ee8298a70.tar.gz |
Respect default manager in DjangoModelFactory (Closes #192).
The previous version tries to use ``cls._default_manager`` all the time,
which breaks with ``manager.using(db_name)``.
Diffstat (limited to 'tests/djapp')
-rw-r--r-- | tests/djapp/models.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/djapp/models.py b/tests/djapp/models.py index 35c765f..96ee5cf 100644 --- a/tests/djapp/models.py +++ b/tests/djapp/models.py @@ -87,3 +87,20 @@ else: class WithSignals(models.Model): foo = models.CharField(max_length=20) + + +class CustomQuerySet(models.QuerySet): + pass + + +class CustomManager(models.Manager): + + def create(self, arg=None, **kwargs): + return super(CustomManager, self).create(**kwargs) + + +class WithCustomManager(models.Model): + + foo = models.CharField(max_length=20) + + objects = CustomManager.from_queryset(CustomQuerySet)() |