Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds "Any" option to AllValuesFilter #134

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion django_filters/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django import forms
from django.db.models import Q
from django.db.models.sql.constants import QUERY_TERMS
from django.db.models.fields import BLANK_CHOICE_DASH
from django.utils import six
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
Expand Down Expand Up @@ -189,5 +190,5 @@ class AllValuesFilter(ChoiceFilter):
def field(self):
qs = self.model._default_manager.distinct()
qs = qs.order_by(self.name).values_list(self.name, flat=True)
self.extra['choices'] = [(o, o) for o in qs]
self.extra['choices'] = BLANK_CHOICE_DASH + [(o, o) for o in qs]
return super(AllValuesFilter, self).field