On 5 jan, 22:52, "Tiago S." <tsera...@gmail.com> wrote: > Hi Bruno, > > > Then how do you store the number of votes per choice ? > > My app is really a quiz with 5 answers per Question and multiples > Question per Quiz. I used the Poll analogy to make easier to explain > what I really need, as the django tutorial is about a Poll app.
Ok. (snip rant about language-specific serialized stuff in db columns) > I agree with you that serialized arrays in a db field is generally a > PITA, > but in this case the quiz, each question can have at most 5 answers, > and > that's it. So I didn't see the need of normalization in this case, > because I would > went with 5 rows in the Answers table for each Question, and the > latter would have > only three fields: id, question_id, and answer_text. Well, then there's another simple denormalization: class Question(models.model): question = models.TextField(...) answer1 = models.TextField(...) answer2 = models.TextField(...) answer3 = models.TextField(...) answer4 = models.TextField(...) answer5 = models.TextField(...) # Then if you want a list-like read access to answers # (which I guess is the case), just add a property: @property def answers(self): return [getattr(self, "answer%s" % i for i in xrange(1, 6)] NB : if you want read/write access, this is a bit more involved but still doable - I posted a possible solution here a couple days ago. My 2 cents --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---