def make_metal_poll(bandname,opinions): pub = timezone.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_text=c,votes=votes)) p = Question(question_text=question,pub_date=pub) p.save() p.choice_set=choices return p