Fixed a regression caused by fix for #21428
On Python 3 sorting Fields mixed with GenericForeignKeys doesn't work as GenericForeignKey isn't a subclass of django.db.models.fields.Field. Refs #21428.
This commit is contained in:
parent
0e079e4331
commit
326539f6a4
|
@ -179,7 +179,11 @@ def fields_for_model(model, fields=None, exclude=None, widgets=None,
|
||||||
field_list = []
|
field_list = []
|
||||||
ignored = []
|
ignored = []
|
||||||
opts = model._meta
|
opts = model._meta
|
||||||
for f in sorted(opts.concrete_fields + opts.virtual_fields + opts.many_to_many):
|
# Avoid circular import
|
||||||
|
from django.db.models.fields import Field as ModelField
|
||||||
|
sortable_virtual_fields = [f for f in opts.virtual_fields
|
||||||
|
if isinstance(f, ModelField)]
|
||||||
|
for f in sorted(opts.concrete_fields + sortable_virtual_fields + opts.many_to_many):
|
||||||
if not getattr(f, 'editable', False):
|
if not getattr(f, 'editable', False):
|
||||||
continue
|
continue
|
||||||
if fields is not None and not f.name in fields:
|
if fields is not None and not f.name in fields:
|
||||||
|
|
Loading…
Reference in New Issue