diff options
| author | Michal Petrucha <michal.petrucha@koniiiik.org> | 2016-03-20 18:10:55 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-04-13 10:10:53 -0400 |
| commit | c339a5a6f72690cd90d5a653dc108fbb60274a20 (patch) | |
| tree | 41b1deef69d5c35b2fc78c67a31d1e647774ae76 /django/forms | |
| parent | 47fbbc33de805c803c39483344854caa2890c32c (diff) | |
Refs #16508 -- Renamed the current "virtual" fields to "private".
The only reason why GenericForeignKey and GenericRelation are stored
separately inside _meta is that they need to be cloned for every model
subclass, but that's not true for any other virtual field. Actually,
it's only true for GenericRelation.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/models.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/django/forms/models.py b/django/forms/models.py index 849f7a111a..aac75b54ff 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -81,7 +81,7 @@ def model_to_dict(instance, fields=None, exclude=None): """ opts = instance._meta data = {} - for f in chain(opts.concrete_fields, opts.virtual_fields, opts.many_to_many): + for f in chain(opts.concrete_fields, opts.private_fields, opts.many_to_many): if not getattr(f, 'editable', False): continue if fields and f.name not in fields: @@ -142,9 +142,8 @@ def fields_for_model(model, fields=None, exclude=None, widgets=None, opts = model._meta # 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(chain(opts.concrete_fields, sortable_virtual_fields, opts.many_to_many)): + sortable_private_fields = [f for f in opts.private_fields if isinstance(f, ModelField)] + for f in sorted(chain(opts.concrete_fields, sortable_private_fields, opts.many_to_many)): if not getattr(f, 'editable', False): if (fields is not None and f.name in fields and (exclude is None or f.name not in exclude)): @@ -431,9 +430,9 @@ class BaseModelForm(BaseForm): fields = self._meta.fields opts = self.instance._meta # Note that for historical reasons we want to include also - # virtual_fields here. (GenericRelation was previously a fake + # private_fields here. (GenericRelation was previously a fake # m2m field). - for f in chain(opts.many_to_many, opts.virtual_fields): + for f in chain(opts.many_to_many, opts.private_fields): if not hasattr(f, 'save_form_data'): continue if fields and f.name not in fields: |
