I've been trying to write a python code that would automatically give me a list from my choices attribute (drf)
that looks like this:
2011/2012
2012/2013
2013/2014
2014/2015
2015/2016
...
But I've failed brutally. Below is my code (tho not doing anything reasonable)
x = xrange(2011, 2015)
y = xrange(2012, 2016)
z = '%5d / %5d' % (x, y)
print '\n'.join(z)
Thanks for the help guys. There's one more thing So I tried to put my out put in my choices attribute in my drf model, it's not giving me any error messages except that when I put
Print z
It includes the output in the console in the server when I run
Python manage.py runserver
This is my code below, I want to be sure that I'm doing the right thing
class studentship(models.Model):
def datechoice():
x = xrange(2011,2016)
y = xrange(2012,2017)
for tup in zip(x,y):
z = '%d/%d' %(tup[0], tup[1])
pick_date = (datechoice())
enroll = models.Charfield(max_Length = 1, choices =
pick_date, default = 'select school session')
Thanks guys for your help, I promise to improve my python hastily.