Asinox
Asinox

Reputation: 6865

Caught ValueError while rendering: need more than 1 value to unpack

im trying to pass a generated "choices" to my model field, please where is the problem?

#models.py
...

def quantity_total():
        for x in range(0,100): return "(" + str(x) + "," + str(x) + "),"

QUANTITY = (quantity_total())

class Package(models.Model):
   ...
   ...
   quantity =  models.SmallIntegerField(choices=QUANTITY, max_length=3)

Thanks guys

Upvotes: 0

Views: 799

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798746

choices is supposed to be an iterable of 2-tuples, not a string.

def quantity_total():
        return ((x, str(x)) for x in xrange(100))

Upvotes: 3

Related Questions