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

OrderingFilter widget select multiple #756

Closed
tamhv opened this issue Aug 6, 2017 · 1 comment
Closed

OrderingFilter widget select multiple #756

tamhv opened this issue Aug 6, 2017 · 1 comment
Labels

Comments

@tamhv
Copy link

tamhv commented Aug 6, 2017

I'm trying to use OrderingFilter, it says "Multiple values may be separated by commas." but users can't pick multiple

class MyFilter(django_filters.FilterSet):
o = django_filters.OrderingFilter(
        fields=(
            ('pk', 'pk'),
            ('first_name', 'first_name'),
            ('email', 'email')
        ),
        field_labels={
            'pk': 'ID',
            'first_name': 'First name',
            'email': 'Email'
        },
    )

screen shot 2017-08-06 at 11 26 19 am

I try to override widget `widget=forms.SelectMultiple` but it doesn't work

'list' object has no attribute 'split'

@rpkilby
Copy link
Collaborator

rpkilby commented Aug 7, 2017

Hi @tamhv. Sorry, the help text is a little misleading here. The quick answer is that you may just want to simply disable the help_text. I'm opening a PR that does this.

The longer answer is that OrderingFilter inherits from BaseCSVFilter and can accept multiple values separated by commas (eg, ?o=pk,first_name). However, this value isn't possible to create with standard HTML select widgets. You would need to have client code that constructed this value for you.

It's also worth noting that SelectMultiple doesn't work here, given that the widget is unable to retain selection order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants