On Jun 19, 3:23 pm, Huuuze <[EMAIL PROTECTED]> wrote: > In this example, what if you wanted to selectively remove a value from > the choice list.
For that you'll have to move the field declaration into the form's __init__ method:: class SomeForm(forms.ModelForm): class Meta: model = SomeModel def __init__(self, *args, **kwargs): super(SomeForm, self).__init__(*args, **kwargs) # Get the base queryset queryset = YourStateModel.objects.all() # Don't forget to pass the instance keyword # when instantiating your form if self.instance: # selectively modify or filter the queryset as needed if self.instance.state == 'processing': queryset = queryset.exclude(state='new') self.fields['car'] = forms.ModelChoiceField(queryset, empty_label=None) --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---