Re: dynamically filling ChoiceField

2008-06-23 Thread Thomas Guettler
Here is how you can modify the form at runtime. You can write a constructor. In this example, I need the request for validation. {{{ class TestForm(forms.ModelForm): class Meta: model=Filter_Test def __init__(self, request, *args, **kwargs): super(TestForm, self).__init__(

Re: dynamically filling ChoiceField

2008-06-22 Thread Calvin Dodge
On Jun 22, 8:08 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote: > Some more details would be good, but off the top of my head, something like > this might work: > > def my_view(request): >form = MyForm() >form.fields['mychoice'].choices = ((1,'ABC'),(2,'XYZ')) Thanks - that's exactly wha

Re: dynamically filling ChoiceField

2008-06-22 Thread Rishabh Manocha
Some more details would be good, but off the top of my head, something like this might work: def my_view(request): form = MyForm() form.fields['mychoice'].choices = ((1,'ABC'),(2,'XYZ')) I havent' been able to test this out, so make sure you do before you using it. You can of-course do any