1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

[1.7.x] Fixed #23112 -- Field.get_choices tries to index an iterable

Backport of 97a38de230 from master.
This commit is contained in:
areski
2014-07-27 23:39:40 +02:00
committed by Florian Apolloner
parent 5736631233
commit e22ad1c325
3 changed files with 54 additions and 4 deletions

View File

@@ -45,6 +45,29 @@ class Whiz(models.Model):
c = models.IntegerField(choices=CHOICES, null=True)
class Counter:
def __init__(self):
self.n = 1
def __iter__(self):
return self
def next(self): # Python 3: def __next__(self)
if self.n > 5:
raise StopIteration
else:
self.n += 1
return (self.n, 'val-'+str(self.n))
class WhizIter(models.Model):
c = models.IntegerField(choices=Counter(), null=True)
class WhizIterEmpty(models.Model):
c = models.CharField(choices=(x for x in []), blank=True, max_length=1)
class BigD(models.Model):
d = models.DecimalField(max_digits=38, decimal_places=30)