<commit_before>class GlobalInitialFormMixin(object):

    """Class initial params for instance initial kwarg"""

    INITIAL = {}

    def __init__(self, *args, **kwargs):
        if kwargs.get('initial', None):
            kwargs['initial'].update(self.INITIAL)
        super(GlobalInitialFormMixin, self).__init__(*args, **kwargs)<commit_msg>Added form mixin for widgets<commit_after>from django import forms

from .widgets import SelectizeCategoryWidget


class GlobalInitialFormMixin(object):

    """Class initial params for instance initial kwarg"""

    INITIAL = {}

    def __init__(self, *args, **kwargs):
        if kwargs.get('initial', None):
            kwargs['initial'].update(self.INITIAL)
        super(GlobalInitialFormMixin, self).__init__(*args, **kwargs)


class SelectizeCategoryFormMixin(object):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        params = {}

        if self.instance is not None:
            params['group_id'] = self.instance.group_id

        self.fields['linked_to'] = forms.ModelChoiceField(
            label=self.fields['linked_to'].label,
            required=self.fields['linked_to'].required,
            queryset=self.Meta.model.objects.all(),
            widget=SelectizeCategoryWidget(self.Meta.model, params=params))
{'fraction_non_alphanumeric': 0.12861491628614916, 'fraction_numerical': 0.0, 'mean_word_length': 3.3833333333333333, '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': '7615360', 'n_tokens_mistral': 375, 'n_tokens_neox': 360, 'n_words': 76}