diff options
| author | areski <areski@gmail.com> | 2014-07-27 23:39:40 +0200 |
|---|---|---|
| committer | Florian Apolloner <florian@apolloner.eu> | 2014-07-30 21:36:01 +0200 |
| commit | e22ad1c3250a59d046d73bf34ae39c0c40e03c98 (patch) | |
| tree | 5808bb699629b1e1de39790861696fd465553d2b /tests/model_fields/models.py | |
| parent | 5736631233f509de8013df7f71c7698783886a28 (diff) | |
[1.7.x] Fixed #23112 -- Field.get_choices tries to index an iterable
Backport of 97a38de230371c0b6ad8a86abba8425186c147c7 from master.
Diffstat (limited to 'tests/model_fields/models.py')
| -rw-r--r-- | tests/model_fields/models.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/model_fields/models.py b/tests/model_fields/models.py index 3888223ad9..b534f218ce 100644 --- a/tests/model_fields/models.py +++ b/tests/model_fields/models.py @@ -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) |
