From df7a65ac4ba36dd155e80b8bcfe607390976ad47 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Tue, 22 May 2012 20:26:46 +0200 Subject: Replaced 'next' testing by collections.Iterator testing. The new construct is also Python 3 compatible (where 'next' has been renamed to '__next__'). --- django/db/models/fields/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'django/db/models/fields') diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index f694958692..50976db339 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -1,3 +1,4 @@ +import collections import copy import datetime import decimal @@ -436,7 +437,7 @@ class Field(object): return bound_field_class(self, fieldmapping, original) def _get_choices(self): - if hasattr(self._choices, 'next'): + if isinstance(self._choices, collections.Iterator): choices, self._choices = tee(self._choices) return choices else: -- cgit v1.3