<commit_before>from django import forms
from django.db import router, models
from django.db.models.query import QuerySet
from django.db.models.fields.related import RelatedField, ForeignObjectRel
from django.utils.functional import cached_property
from django.core.exceptions import ImproperlyConfigured, ValidationError
from djangae.forms.fields import (
    encode_pk,
    GenericRelationFormfield
)
from django.utils import six

class RelatedIteratorRel(ForeignObjectRel):
    def __init__(self, field, to, related_name=None, limit_choices_to=None):
        self.field = field
        self.to = to
        self.related_name = related_name
        self.related_query_name = None
        self.field_name = None
        self.parent_link = None
        self.on_delete = models.DO_NOTHING
        self.symmetrical = False

        if limit_choices_to is None:
            limit_choices_to = {}
        self.limit_choices_to = limit_choices_to
        self.multiple = True

    def is_hidden(self):
        "Should the related object be hidden?"
        return self.related_name and self.related_name[-1] == '+'

    def set_field_name(self):
        self.field_name = self.field_name or self.to._meta.pk.name

    def get_related_field(self):
        """
        Returns the field in the to' object to which this relationship is tied
        (this is always the primary key on the target model). Provided for
        symmetry with ManyToOneRel.
        """
        return self.to._meta.pk


class OrderedQuerySet(QuerySet):

    def _fetch_all(self):
        """
            Fetch all uses the standard iterator but sorts the values on the
            way out, this maintains the lazy evaluation of querysets
        """
        if self._result_cache is None:
            results = list(self.iterator())
            ordered_results = []
            pk_hash = {x.pk: x for x in results}
            for pk in self.ordered_pks:
                obj = pk_hash.get(pk)
                if obj:<commit_msg>Replaced depreacted to attribute with model attribute on related fields<commit_after>from django import forms
from django.db import router, models
from django.db.models.query import QuerySet
from django.db.models.fields.related import RelatedField, ForeignObjectRel
from django.utils.functional import cached_property
from django.core.exceptions import ImproperlyConfigured, ValidationError
from djangae.forms.fields import (
    encode_pk,
    GenericRelationFormfield
)
from django.utils import six

class RelatedIteratorRel(ForeignObjectRel):
    def __init__(self, field, to, related_name=None, limit_choices_to=None):
        self.field = field
        self.model = to
        self.related_name = related_name
        self.related_query_name = None
        self.field_name = None
        self.parent_link = None
        self.on_delete = models.DO_NOTHING
        self.symmetrical = False

        if limit_choices_to is None:
            limit_choices_to = {}
        self.limit_choices_to = limit_choices_to
        self.multiple = True

    def is_hidden(self):
        "Should the related object be hidden?"
        return self.related_name and self.related_name[-1] == '+'

    def set_field_name(self):
        self.field_name = self.field_name or self.model._meta.pk.name

    def get_related_field(self):
        """
        Returns the field in the to' object to which this relationship is tied
        (this is always the primary key on the target model). Provided for
        symmetry with ManyToOneRel.
        """
        return self.model._meta.pk


class OrderedQuerySet(QuerySet):

    def _fetch_all(self):
        """
            Fetch all uses the standard iterator but sorts the values on the
            way out, this maintains the lazy evaluation of querysets
        """
        if self._result_cache is None:
            results = list(self.iterator())
            ordered_results = []
            pk_hash = {x.pk: x for x in results}
            for pk in self.ordered_pks:
                obj = pk_hash.get(pk)
                if obj:
{'fraction_non_alphanumeric': 0.06894853484363457, 'fraction_numerical': 0.0004924895345973898, 'mean_word_length': 2.5199306759098787, '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': '7287515', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1110, 'n_words': 340}