mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
Removed ChoicesMeta per deprecation timeline.
This commit is contained in:
parent
b4bc393b23
commit
55f71b195b
@ -1,7 +1,5 @@
|
|||||||
import enum
|
import enum
|
||||||
import warnings
|
|
||||||
|
|
||||||
from django.utils.deprecation import RemovedInDjango60Warning
|
|
||||||
from django.utils.functional import Promise
|
from django.utils.functional import Promise
|
||||||
from django.utils.version import PY311, PY312
|
from django.utils.version import PY311, PY312
|
||||||
|
|
||||||
@ -110,14 +108,3 @@ class TextChoices(Choices, StrEnum):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _generate_next_value_(name, start, count, last_values):
|
def _generate_next_value_(name, start, count, last_values):
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
def __getattr__(name):
|
|
||||||
if name == "ChoicesMeta":
|
|
||||||
warnings.warn(
|
|
||||||
"ChoicesMeta is deprecated in favor of ChoicesType.",
|
|
||||||
RemovedInDjango60Warning,
|
|
||||||
stacklevel=2,
|
|
||||||
)
|
|
||||||
return ChoicesType
|
|
||||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
||||||
|
@ -283,6 +283,9 @@ to remove usage of these features.
|
|||||||
|
|
||||||
* Support for ``cx_Oracle`` is removed.
|
* Support for ``cx_Oracle`` is removed.
|
||||||
|
|
||||||
|
* The ``ChoicesMeta`` alias to ``django.db.models.enums.ChoicesType`` is
|
||||||
|
removed.
|
||||||
|
|
||||||
See :ref:`deprecated-features-5.1` for details on these changes, including how
|
See :ref:`deprecated-features-5.1` for details on these changes, including how
|
||||||
to remove usage of these features.
|
to remove usage of these features.
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import uuid
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.template import Context, Template
|
from django.template import Context, Template
|
||||||
from django.test import SimpleTestCase
|
from django.test import SimpleTestCase
|
||||||
from django.utils.deprecation import RemovedInDjango60Warning
|
|
||||||
from django.utils.functional import Promise
|
from django.utils.functional import Promise
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.utils.version import PY311
|
from django.utils.version import PY311
|
||||||
@ -321,13 +320,3 @@ class CustomChoicesTests(SimpleTestCase):
|
|||||||
|
|
||||||
class Identifier(uuid.UUID, models.Choices):
|
class Identifier(uuid.UUID, models.Choices):
|
||||||
A = "972ce4eb-a95f-4a56-9339-68c208a76f18"
|
A = "972ce4eb-a95f-4a56-9339-68c208a76f18"
|
||||||
|
|
||||||
|
|
||||||
class ChoicesMetaDeprecationTests(SimpleTestCase):
|
|
||||||
def test_deprecation_warning(self):
|
|
||||||
from django.db.models import enums
|
|
||||||
|
|
||||||
msg = "ChoicesMeta is deprecated in favor of ChoicesType."
|
|
||||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
|
|
||||||
enums.ChoicesMeta
|
|
||||||
self.assertEqual(ctx.filename, __file__)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user