From 933dc62742d2ba374fb0f03bd29022dfb60f52ec Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sat, 31 Dec 2016 11:54:49 -0500 Subject: [PATCH] Refs #16508 -- Removed virtual aliases of "private fields". Per deprecation timeline. --- django/db/models/fields/__init__.py | 10 +--------- django/db/models/options.py | 19 +------------------ docs/releases/2.0.txt | 5 +++++ 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 2018797564..cf3aab4815 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -27,7 +27,6 @@ from django.utils.datastructures import DictWrapper from django.utils.dateparse import ( parse_date, parse_datetime, parse_duration, parse_time, ) -from django.utils.deprecation import RemovedInDjango20Warning from django.utils.duration import duration_string from django.utils.encoding import ( force_bytes, force_text, python_2_unicode_compatible, smart_text, @@ -673,7 +672,7 @@ class Field(RegisterLookupMixin): if self.verbose_name is None and self.name: self.verbose_name = self.name.replace('_', ' ') - def contribute_to_class(self, cls, name, private_only=False, virtual_only=NOT_PROVIDED): + def contribute_to_class(self, cls, name, private_only=False): """ Register the field with the model class it belongs to. @@ -681,13 +680,6 @@ class Field(RegisterLookupMixin): created for every subclass of cls, even if cls is not an abstract model. """ - if virtual_only is not NOT_PROVIDED: - warnings.warn( - "The `virtual_only` argument of Field.contribute_to_class() " - "has been renamed to `private_only`.", - RemovedInDjango20Warning, stacklevel=2 - ) - private_only = virtual_only self.set_attributes_from_name(name) self.model = cls if private_only: diff --git a/django/db/models/options.py b/django/db/models/options.py index 335289beea..c4652870e0 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -19,15 +19,12 @@ from django.utils import six from django.utils.datastructures import ImmutableList, OrderedSet from django.utils.deprecation import ( RemovedInDjango20Warning, RemovedInDjango21Warning, - warn_about_renamed_method, ) from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.functional import cached_property from django.utils.text import camel_case_to_spaces, format_lazy from django.utils.translation import override -NOT_PROVIDED = object() - PROXY_PARENTS = object() EMPTY_RELATION_TREE = tuple() @@ -259,13 +256,7 @@ class Options(object): self.local_managers.append(manager) self._expire_cache() - def add_field(self, field, private=False, virtual=NOT_PROVIDED): - if virtual is not NOT_PROVIDED: - warnings.warn( - "The `virtual` argument of Options.add_field() has been renamed to `private`.", - RemovedInDjango20Warning, stacklevel=2 - ) - private = virtual + def add_field(self, field, private=False): # Insert the given field in the order in which it was created, using # the "creation_counter" attribute of the field. # Move many-to-many related fields from self.fields into @@ -516,14 +507,6 @@ class Options(object): "concrete_fields", (f for f in self.fields if f.concrete) ) - @property - @warn_about_renamed_method( - 'Options', 'virtual_fields', 'private_fields', - RemovedInDjango20Warning - ) - def virtual_fields(self): - return self.private_fields - @cached_property def local_concrete_fields(self): """ diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index f02520cb9e..385b25b28d 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -361,3 +361,8 @@ these features. * Using ``User.is_authenticated()`` and ``User.is_anonymous()`` as methods rather than properties is no longer be supported. + +* The ``Model._meta.virtual_fields`` attribute is removed. + +* The keyword arguments ``virtual_only`` in ``Field.contribute_to_class()`` and + ``virtual`` in ``Model._meta.add_field()`` are removed.