summaryrefslogtreecommitdiff
path: root/factory/base.py
diff options
context:
space:
mode:
authorEduard Iskandarov <edikexp@gmail.com>2012-11-19 13:41:43 +0600
committerRaphaël Barrois <raphael.barrois@polyconseil.fr>2012-12-09 01:32:17 +0100
commitb449fbf4d9f7d9b93b1c0f400cf562953b209534 (patch)
tree2c47943a975a63cff268f52a34835c6ed3106a4c /factory/base.py
parent63c88fb17db0156606b87f4014b2b6275b261564 (diff)
downloadfactory-boy-b449fbf4d9f7d9b93b1c0f400cf562953b209534.tar
factory-boy-b449fbf4d9f7d9b93b1c0f400cf562953b209534.tar.gz
Fix pk lookup in _setup_next_sequence method.
Closes #31 Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
Diffstat (limited to 'factory/base.py')
-rw-r--r--factory/base.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/factory/base.py b/factory/base.py
index 2b78e2b..8de652d 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -654,10 +654,10 @@ class DjangoModelFactory(Factory):
@classmethod
def _setup_next_sequence(cls):
- """Compute the next available ID, based on the 'id' database field."""
+ """Compute the next available PK, based on the 'pk' database field."""
try:
- return 1 + cls._associated_class._default_manager.values_list('id', flat=True
- ).order_by('-id')[0]
+ return 1 + cls._associated_class._default_manager.values_list('pk', flat=True
+ ).order_by('-pk')[0]
except IndexError:
return 1