From 96a303aaffbc8315276711b3934bec4c9b6a322b Mon Sep 17 00:00:00 2001 From: Morgan Curley Date: Wed, 15 May 2013 18:59:41 -0400 Subject: [PATCH] Incrementing the _setup_next_sequence fails if the pk is a non integer. Added except clause that will catch TypeErrors and return 1 + the count of existing records --- factory/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/factory/base.py b/factory/base.py index c8c7f06..1218c20 100644 --- a/factory/base.py +++ b/factory/base.py @@ -660,6 +660,8 @@ def _setup_next_sequence(cls): ).order_by('-pk')[0] except IndexError: return 1 + except TypeError: + return manager.count() + 1 @classmethod def _create(cls, target_class, *args, **kwargs):