From ab3e3658cc67debaf90b747fd24ecd1d49b31bf3 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Thu, 31 Aug 2017 16:11:30 +0500 Subject: [PATCH] Simplified model's Options._get_fields() a bit. --- django/db/models/options.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/django/db/models/options.py b/django/db/models/options.py index 3a4a33e7f9..c81a61c916 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -4,7 +4,6 @@ import warnings from bisect import bisect from collections import OrderedDict, defaultdict from contextlib import suppress -from itertools import chain from django.apps import apps from django.conf import settings @@ -786,18 +785,15 @@ class Options: fields.append(field.remote_field) if forward: - fields.extend( - field for field in chain(self.local_fields, self.local_many_to_many) - ) + fields += self.local_fields + fields += self.local_many_to_many # Private fields are recopied to each child model, and they get a # different model as field.model in each child. Hence we have to # add the private fields separately from the topmost call. If we # did this recursively similar to local_fields, we would get field # instances with field.model != self.model. if topmost_call: - fields.extend( - f for f in self.private_fields - ) + fields += self.private_fields # In order to avoid list manipulation. Always # return a shallow copy of the results