On Mar 30, 2:10 pm, Thomas <thomasje...@gmail.com> wrote: > I already found a solution by myself: > > doing this into the forms.py inside the class does the trick: > > def __init__(self, *args, **kwargs): > super(FilterForm, self) .__init__(*args, **kwargs) > self.fields['host'].choices = > Test.objects.values_list('hostname', 'hostname').distinct()
You don't need anything that complicated, the original code just had a mistake- you need to put the ".distinct()" at the end of the query, not the field definition! Compare: orms.ModelMultipleChoiceField(queryset=Events.objects.values('hostname'), required=False).distinct() and: orms.ModelMultipleChoiceField(queryset=Events.objects.values('hostname').distinct(), required=False) Peter -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.