<commit_before>from django import forms
from django.forms.models import inlineformset_factory
from django.forms.models import BaseInlineFormSet
from django.forms.util import ErrorList

from ..models import EnginePatch, Engine


class EnginePatchForm(forms.ModelForm):

    def clean(self):
        """This method validates patch_path as required field when the form is
        not checked as Delete or is_initial_patch = True. The error message is
        added directly into the field.
        """
        super(EnginePatchForm, self).clean()
<commit_msg>Implementing custom choice field - Changing display value<commit_after>from django import forms
from django.forms.models import inlineformset_factory
from django.forms.models import BaseInlineFormSet
from django.forms.util import ErrorList

from ..models import EnginePatch, Engine


class EquivalentPatchCustomChoiceField(forms.ModelChoiceField):

    def label_from_instance(self, obj):
        return "{} - {}
".format(obj.engine.engine_type, obj)


class EnginePatchForm(forms.ModelForm):

    migrate_engine_equivalent_patch = EquivalentPatchCustomChoiceField(queryset=EnginePatch.objects.all())

    def clean(self):
        """This method validates patch_path as required field when the form is
        not checked as Delete or is_initial_patch = True. The error message is
        added directly into the field.
        """
        super(EnginePatchForm, self).clean()

{'fraction_non_alphanumeric': 0.06838799720865317, 'fraction_numerical': 0.0, 'mean_word_length': 4.085106382978723, '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': '3087537', 'n_tokens_mistral': 368, 'n_tokens_neox': 362, 'n_words': 124}