How to use newforms ChoiceField to show dynamic choices

2008-01-24 Thread shabda
I want to use the ChoiceField to show choices depending on a query set. For exmple the ChoiceField must get all active Users and them show them in a drop down, something like what happens in Admin. How can I do that? --~--~-~--~~~---~--~~ You received this message b

Re: How to use newforms ChoiceField to show dynamic choices

2008-01-24 Thread Nathaniel Whiteinge
ModelChoiceField. Currently not documented, but here's example code. Use your browser's find for "ModelChoiceField". http://www.djangoproject.com/documentation/models/model_forms/ On Jan 24, 9:47 pm, shabda <[EMAIL PROTECTED]> wrote: > I want to use the ChoiceField to show choices depending on

Re: How to use newforms ChoiceField to show dynamic choices

2008-01-25 Thread Artiom Diomin
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 YourCoolForm(forms.ModelForm): ~choices_field = forms.ModelChoiceField( ~queryset=UserProfile.objects.all()) ~def__init__(self, **kwargs): ~ super(YourCoolForm, self).__init__(**kwargs) ~ self.fields['choices_field'].q

Re: How to use newforms ChoiceField to show dynamic choices

2008-01-25 Thread ikks
I have mod_python and I'm using ModelChoiceField, but I'm not getting the expected results, when I change my queryset and the second has elements not present on the original queryset, it displays the choices but doesn't validate properly, complaining about the option not being valid for the set.