def make_metal_poll(bandname, opinions): pub = datetime.datetime.now() marks = '?' * random.randint(1, 5) question = bandname + marks chosen = random.sample(opinions, 5) choices = list() for c in chosen: votes = random.randint(1, 1000) choices.append(Choice(choice=c, votes=votes)) p = Poll(question=question, pub_date=pub) p.save() p.choice_set = choices return p
def make_metal_poll(bandname,opinions): pub = datetime.datetime.now() marks = '?' * random.randint(1,5) question = bandname + marks chosen = random.sample(opinions,5) choices = list() for c in chosen: votes = random.randint(1,1000) choices.append(Choice(choice=c,votes=votes)) p = Poll(question=question,pub_date=pub) p.save() p.choice_set=choices return p