diff --git a/django/db/models/query.py b/django/db/models/query.py index 8bd981d..03ee312 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -463,6 +463,9 @@ class QuerySet(object): Returns a tuple of (object, created), where created is a boolean specifying whether an object was created. """ + if callable(defaults): + defaults = defaults() + lookup, params = self._extract_model_params(defaults, **kwargs) # The get() needs to be targeted at the write database in order # to avoid potential transaction consistency problems. @@ -480,6 +483,9 @@ class QuerySet(object): specifying whether an object was created. """ defaults = defaults or {} + if callable(defaults): + defaults = defaults() + lookup, params = self._extract_model_params(defaults, **kwargs) self._for_write = True try: