<commit_before>from rest_framework import serializers, viewsets

from democracy.models import Label
from democracy.pagination import DefaultLimitPagination


class LabelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Label
        fields = ('id', 'label')


class LabelViewSet(viewsets.ReadOnlyModelViewSet):
    serializer_class = LabelSerializer
    queryset = Label.objects.all()
    pagination_class = DefaultLimitPagination<commit_msg>Add label name filter for autocomplete purposes<commit_after>from rest_framework import serializers, viewsets, filters
import django_filters

from democracy.models import Label
from democracy.pagination import DefaultLimitPagination

class LabelFilter(django_filters.FilterSet):
    label = django_filters.CharFilter(lookup_type='icontains')

    class Meta:
        model = Label
        fields = ['label']


class LabelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Label
        fields = ('id', 'label')


class LabelViewSet(viewsets.ReadOnlyModelViewSet):
    serializer_class = LabelSerializer
    queryset = Label.objects.all()
    pagination_class = DefaultLimitPagination
    filter_backends = (filters.DjangoFilterBackend,)
    filter_class = LabelFilter
{'fraction_non_alphanumeric': 0.06937799043062201, 'fraction_numerical': 0.0, 'mean_word_length': 4.704545454545454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6166598', 'n_tokens_mistral': 324, 'n_tokens_neox': 323, 'n_words': 82}