Django-filter ModelChoiceFilter using queryset
I'm using django-filter and I have my model log :
class Log(models.Model):
admin = models.CharField(max_length=64)
appli = models.CharField(max_length=64)
| ID | ADMIN | APPLI |
|---|---|---|
| 1 | LEA | VM |
| 2 | FRANCIS | VEEAM |
| 3 | LOREN | OBJECTS |
I want to filter ADMIN and APPLI with a Select field related to the model Log like this :
<select class='form-control'>
<option>LEA</option>
<option>FRANCIS</option>
<option>LOREM</option>
</select>
by using ModelChoiceFilter. I tried something like this but the search is not working probably because value_list return a tulp.
admin = django_filters.ModelMultipleChoiceFilter(
queryset=Log.objects.distinct().values_list('admin', flat=True))
Is there another way to do it ?