> How can I cast this 2 values dictionary into a 2 values tuple?
Why are you creating a dict here?
Try something like this:
choices = []
for i in range(100):
choices.append( (i, i+1) )
SONGNO_CHOICES = choices
Or more concisely:
SONGNO_CHOICES= [ (i,i+1) for i in range(100) ]
This gives you
Hi, I'm creating a model with a field as follows:
trackno = models.PositiveSmallIntegerField(choices=SONGNO_CHOICES)
I try to create the SONGNO_CHOICES tuple with this code:
dict = {}
j = 0
while j<100:
dict[j]=(j,j+1)
j=j+1
SONGNO_CHOICES = dict
When a try to validate my model, Djang
2 matches
Mail list logo