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

dynamically filling ChoiceField

2008-06-22 Thread Calvin Dodge
I've been tearing out what little hair I have left trying to figure this out. How do I dynamically fill a ChoiceField by filtering on a value known to the URLView? Every "dynamic fill" example I've found assumes the form knows it all - I haven't seen anything which shows me how to pass that value