mirror of https://github.com/django/django.git
This reverts commit 57793b4765
.
This commit is contained in:
parent
a1e9e9abc5
commit
66f30dbf25
|
@ -24,7 +24,6 @@ from django.utils.dateparse import (
|
|||
parse_duration,
|
||||
parse_time,
|
||||
)
|
||||
from django.utils.deprecation import DeprecationForHistoricalMigrationMixin
|
||||
from django.utils.duration import duration_microseconds, duration_string
|
||||
from django.utils.functional import Promise, cached_property
|
||||
from django.utils.ipv6 import clean_ipv6_address
|
||||
|
@ -112,7 +111,7 @@ def return_None():
|
|||
|
||||
|
||||
@total_ordering
|
||||
class Field(DeprecationForHistoricalMigrationMixin, RegisterLookupMixin):
|
||||
class Field(RegisterLookupMixin):
|
||||
"""Base class for all field types"""
|
||||
|
||||
# Designates whether empty strings fundamentally are allowed at the
|
||||
|
@ -138,7 +137,8 @@ class Field(DeprecationForHistoricalMigrationMixin, RegisterLookupMixin):
|
|||
"%(date_field_label)s %(lookup_type)s."
|
||||
),
|
||||
}
|
||||
check_type = "fields"
|
||||
system_check_deprecated_details = None
|
||||
system_check_removed_details = None
|
||||
|
||||
# Attributes that don't affect a column definition.
|
||||
# These attributes are ignored when altering the field.
|
||||
|
@ -263,7 +263,7 @@ class Field(DeprecationForHistoricalMigrationMixin, RegisterLookupMixin):
|
|||
*self._check_null_allowed_for_primary_keys(),
|
||||
*self._check_backend_specific_checks(**kwargs),
|
||||
*self._check_validators(),
|
||||
*self.check_deprecation_details(),
|
||||
*self._check_deprecation_details(),
|
||||
]
|
||||
|
||||
def _check_field_name(self):
|
||||
|
@ -441,6 +441,33 @@ class Field(DeprecationForHistoricalMigrationMixin, RegisterLookupMixin):
|
|||
)
|
||||
return errors
|
||||
|
||||
def _check_deprecation_details(self):
|
||||
if self.system_check_removed_details is not None:
|
||||
return [
|
||||
checks.Error(
|
||||
self.system_check_removed_details.get(
|
||||
"msg",
|
||||
"%s has been removed except for support in historical "
|
||||
"migrations." % self.__class__.__name__,
|
||||
),
|
||||
hint=self.system_check_removed_details.get("hint"),
|
||||
obj=self,
|
||||
id=self.system_check_removed_details.get("id", "fields.EXXX"),
|
||||
)
|
||||
]
|
||||
elif self.system_check_deprecated_details is not None:
|
||||
return [
|
||||
checks.Warning(
|
||||
self.system_check_deprecated_details.get(
|
||||
"msg", "%s has been deprecated." % self.__class__.__name__
|
||||
),
|
||||
hint=self.system_check_deprecated_details.get("hint"),
|
||||
obj=self,
|
||||
id=self.system_check_deprecated_details.get("id", "fields.WXXX"),
|
||||
)
|
||||
]
|
||||
return []
|
||||
|
||||
def get_col(self, alias, output_field=None):
|
||||
if alias == self.model._meta.db_table and (
|
||||
output_field is None or output_field == self
|
||||
|
|
|
@ -157,42 +157,3 @@ class MiddlewareMixin:
|
|||
thread_sensitive=True,
|
||||
)(request, response)
|
||||
return response
|
||||
|
||||
|
||||
class DeprecationForHistoricalMigrationMixin:
|
||||
system_check_deprecated_details = None
|
||||
system_check_removed_details = None
|
||||
check_type = ""
|
||||
|
||||
def check_deprecation_details(self):
|
||||
from django.core import checks
|
||||
|
||||
if self.system_check_removed_details is not None:
|
||||
return [
|
||||
checks.Error(
|
||||
self.system_check_removed_details.get(
|
||||
"msg",
|
||||
"%s has been removed except for support in historical "
|
||||
"migrations." % self.__class__.__name__,
|
||||
),
|
||||
hint=self.system_check_removed_details.get("hint"),
|
||||
obj=self,
|
||||
id=self.system_check_removed_details.get(
|
||||
"id", f"{self.check_type}.EXXX"
|
||||
),
|
||||
)
|
||||
]
|
||||
elif self.system_check_deprecated_details is not None:
|
||||
return [
|
||||
checks.Warning(
|
||||
self.system_check_deprecated_details.get(
|
||||
"msg", "%s has been deprecated." % self.__class__.__name__
|
||||
),
|
||||
hint=self.system_check_deprecated_details.get("hint"),
|
||||
obj=self,
|
||||
id=self.system_check_deprecated_details.get(
|
||||
"id", f"{self.check_type}.WXXX"
|
||||
),
|
||||
)
|
||||
]
|
||||
return []
|
||||
|
|
Loading…
Reference in New Issue