mirror of https://github.com/django/django.git
Refs #16508 -- Removed virtual aliases of "private fields".
Per deprecation timeline.
This commit is contained in:
parent
eba093e8b0
commit
933dc62742
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue