[Fixed]-How can I customize a drop-down list form element in django?

1👍

Don’t know what field you want to filter, but you could do it like this:

class A(forms.ModelForm):
    class Meta:
        model = ModelA

    def __init__(self, *args, **kwargs):
        super(A, self).__init__(*args, **kwargs)
        self.fields['your_field'].queryset = self.fields['your_field'].queryset \
                .filter(some_filter_value=1)

Leave a comment