Simplified model's Options._get_fields() a bit.

This commit is contained in:
Sergey Fedoseev 2017-08-31 16:11:30 +05:00 committed by Tim Graham
parent 20a761697f
commit ab3e3658cc
1 changed files with 3 additions and 7 deletions

View File

@ -4,7 +4,6 @@ import warnings
from bisect import bisect from bisect import bisect
from collections import OrderedDict, defaultdict from collections import OrderedDict, defaultdict
from contextlib import suppress from contextlib import suppress
from itertools import chain
from django.apps import apps from django.apps import apps
from django.conf import settings from django.conf import settings
@ -786,18 +785,15 @@ class Options:
fields.append(field.remote_field) fields.append(field.remote_field)
if forward: if forward:
fields.extend( fields += self.local_fields
field for field in chain(self.local_fields, self.local_many_to_many) fields += self.local_many_to_many
)
# Private fields are recopied to each child model, and they get a # Private fields are recopied to each child model, and they get a
# different model as field.model in each child. Hence we have to # different model as field.model in each child. Hence we have to
# add the private fields separately from the topmost call. If we # add the private fields separately from the topmost call. If we
# did this recursively similar to local_fields, we would get field # did this recursively similar to local_fields, we would get field
# instances with field.model != self.model. # instances with field.model != self.model.
if topmost_call: if topmost_call:
fields.extend( fields += self.private_fields
f for f in self.private_fields
)
# In order to avoid list manipulation. Always # In order to avoid list manipulation. Always
# return a shallow copy of the results # return a shallow copy of the results