<commit_before>from django.db.models.fields import FieldDoesNotExist
from django.db.models.fields.related import ForeignObjectRel, OneToOneRel
from django_filters import BooleanFilter, DateFilter, NumberFilter
from rest_framework import filters

from api.generics.filters import (
    CommaSeparatedCharFilter, TogetherFilterSet, ToManyFilter
)
from iati.models import (
    ActivityParticipatingOrganisation, ActivityRecipientCountry,
    ActivityRecipientRegion, ActivityReportingOrganisation, ActivitySector,
    Budget, RelatedActivity, ResultIndicatorTitle
)
from iati.transaction.models import Transaction


class BudgetFilter(TogetherFilterSet):

    activity_id = CommaSeparatedCharFilter(
        field_name='activity__iati_identifier',
        lookup_expr='in')

    iati_identifier = CommaSeparatedCharFilter(
        name='activity__iati_identifier',
        lookup_expr='in')

    activity_scope = CommaSeparatedCharFilter(
        field_name='activity__scope__code',
        lookup_expr='in',)

    document_link_category = CommaSeparatedCharFilter(<commit_msg>Fixed activity_scope call returning server error 500, the field was missing a filter for has_activity_scope in budget/filters.py<commit_after>from django.db.models.fields import FieldDoesNotExist
from django.db.models.fields.related import ForeignObjectRel, OneToOneRel
from django_filters import BooleanFilter, DateFilter, NumberFilter
from rest_framework import filters

from api.generics.filters import (
    CommaSeparatedCharFilter, TogetherFilterSet, ToManyFilter, IsNullBooleanFilter
)
from iati.models import (
    ActivityParticipatingOrganisation, ActivityRecipientCountry,
    ActivityRecipientRegion, ActivityReportingOrganisation, ActivitySector,
    Budget, RelatedActivity, ResultIndicatorTitle
)
from iati.transaction.models import Transaction


class BudgetFilter(TogetherFilterSet):

    activity_id = CommaSeparatedCharFilter(
        field_name='activity__iati_identifier',
        lookup_expr='in')

    iati_identifier = CommaSeparatedCharFilter(
        name='activity__iati_identifier',
        lookup_expr='in')

    activity_scope = CommaSeparatedCharFilter(
        field_name='activity__scope__code',
        lookup_expr='in',)

    has_activity_scope = IsNullBooleanFilter(
        name='activity__scope__code',
        lookup_expr='isnull',
    )

    document_link_category = CommaSeparatedCharFilter(
{'fraction_non_alphanumeric': 0.06190278354798504, 'fraction_numerical': 0.0012463647694225177, 'mean_word_length': 5.421333333333333, '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': '2819705', 'n_tokens_mistral': 660, 'n_tokens_neox': 628, 'n_words': 132}