Use custom select option labels for ModelMultipleChoiceFilter
instead of __str__(self)
?
#1656
-
I am using the As I already provide a custom queryset, I would like to provide a custom "label template" or overwrite the default select option labels: def authors_site_scoped(request):
return Author.objects.filter(...).distinct()
class PublicationFilter(django_filters.FilterSet):
authors_filter = django_filters.ModelMultipleChoiceFilter(
field_name="authors",
queryset=authors_site_scoped,
)
class Meta:
model = Publication
form = PublicationFilterForm
fields = (
"authors_filter",
) Is that possible? And if: how :-)? |
Beta Was this translation helpful? Give feedback.
Answered by
carltongibson
May 8, 2024
Replies: 1 comment 1 reply
-
https://docs.djangoproject.com/en/5.0/ref/forms/fields/#django.forms.ModelChoiceField.iterator |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
tombreit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://docs.djangoproject.com/en/5.0/ref/forms/fields/#django.forms.ModelChoiceField.iterator