andraeas, You can define a choice field that takes a callable as it's choices. That way you could use the current year and loop over the subsequent years to create the list you need. Just return a two tuple that can be used as the choices for a normal field in your function.
class LazyChoiceField(ChoiceField): def _get_choices(self): if callable(self._choices): return self._choices() return self._choices def _set_choices(self, value): self._choices = self.widget.choices = value choices = property(_get_choices, _set_choices) On Wed, Nov 11, 2009 at 8:10 PM, andreas schmid <a.schmi...@gmail.com> wrote: > > hi , > > i need to create an input form with a input field for every month for > lets say 10 years. > so the form has 10*12 = 120 exact same input fields. > > is there a way to define the field only once or maybe define a year with > 12 fields and loop over it to avoid having a huge model? > > thx > > > > -- ======================================= 株式会社ビープラウド イアン・ルイス 〒150-0012 東京都渋谷区広尾1-11-2アイオス広尾ビル604 email: ianmle...@beproud.jp TEL:03-5795-2707 FAX:03-5795-2708 http://www.beproud.jp/ ======================================= --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---