Hello again Bruno! This solution is neat, thanks for that. I didn't know about getattr until now.
Regards, Tiago On Jan 5, 9:05 pm, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > 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 -~----------~----~----~----~------~----~------~--~---