diff options
-rw-r--r-- | factory/django.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/factory/django.py b/factory/django.py index b3c508c..43434c2 100644 --- a/factory/django.py +++ b/factory/django.py @@ -29,6 +29,8 @@ import types import logging import functools +from . import errors + """factory_boy extensions for use with the Django framework.""" try: @@ -157,6 +159,11 @@ class DjangoModelFactory(base.Factory): key_fields = {} for field in cls._meta.django_get_or_create: + if field not in kwargs: + raise errors.FactoryError( + "django_get_or_create - " + "Unable to find initialization value for '%s' in factory %s" % + (field, cls.__name__)) key_fields[field] = kwargs.pop(field) key_fields['defaults'] = kwargs |