Reputation: 6865
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
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