From ae01b0c5cb86ba68a0eeaac87b31206d9a4023bf Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Tue, 23 Feb 2010 18:40:07 +0000 Subject: [PATCH] [1.1.X] Fixed a few more spots related to #11859. Backport of r12537 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12538 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/fields/__init__.py | 2 +- django/forms/fields.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 2a7c17f876..d3eee8aeb6 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -304,7 +304,7 @@ class Field(object): """Flattened version of choices tuple.""" flat = [] for choice, value in self.choices: - if type(value) in (list, tuple): + if isinstance(value, (list, tuple)): flat.extend(value) else: flat.append((choice,value)) diff --git a/django/forms/fields.py b/django/forms/fields.py index 581d32d923..18174360f6 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -660,7 +660,7 @@ class ChoiceField(Field): def valid_value(self, value): "Check to see if the provided value is a valid choice" for k, v in self.choices: - if type(v) in (tuple, list): + if isinstance(v, (list, tuple)): # This is an optgroup, so look inside the group for options for k2, v2 in v: if value == smart_unicode(k2):