Python django_filters.rest_framework.MultipleChoiceFilter() Examples

The following are 1 code examples of django_filters.rest_framework.MultipleChoiceFilter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django_filters.rest_framework , or try the search function .
Example #1
Source File: filters.py    From OasisPlatform with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def get_coreschema_field(self, field):
        description = six.text_type(field.extra.get('help_text', ''))

        if isinstance(field, filters.NumberFilter):
            return coreschema.Number(description=description)
        elif isinstance(field, filters.MultipleChoiceFilter):
            return coreschema.Array(
                items=coreschema.Enum(enum=[c[0] for c in field.field.choices]),
                description=description,
                unique_items=True,
            )
        elif isinstance(field, filters.ChoiceFilter):
            return coreschema.Enum(
                enum=[c[0] for c in field.field.choices],
                description=description
            )
        else:
            return coreschema.String(description=description)