mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
deprecation warnings for the global settings
This commit is contained in:
parent
5d5a4ce44b
commit
cd5bb1ea4a
@ -27,6 +27,10 @@ STATICFILES_STORAGE_ALIAS = "staticfiles"
|
|||||||
FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG = (
|
FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG = (
|
||||||
"The FORMS_URLFIELD_ASSUME_HTTPS transitional setting is deprecated."
|
"The FORMS_URLFIELD_ASSUME_HTTPS transitional setting is deprecated."
|
||||||
)
|
)
|
||||||
|
DEFAULT_TABLESPACE_DEPRECATED_MSG = "The DEFAULT_TABLESPACE setting is deprecated."
|
||||||
|
DEFAULT_INDEX_TABLESPACE_DEPRECATED_MSG = (
|
||||||
|
"The DEFAULT_INDEX_TABLESPACE setting is deprecated."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SettingsReference(str):
|
class SettingsReference(str):
|
||||||
@ -192,6 +196,18 @@ class Settings:
|
|||||||
RemovedInDjango60Warning,
|
RemovedInDjango60Warning,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.is_overridden("DEFAULT_TABLESPACE"):
|
||||||
|
warnings.warn(
|
||||||
|
DEFAULT_TABLESPACE_DEPRECATED_MSG,
|
||||||
|
RemovedInDjango60Warning,
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.is_overridden("DEFAULT_INDEX_TABLESPACE"):
|
||||||
|
warnings.warn(
|
||||||
|
DEFAULT_INDEX_TABLESPACE_DEPRECATED_MSG,
|
||||||
|
RemovedInDjango60Warning,
|
||||||
|
)
|
||||||
|
|
||||||
if hasattr(time, "tzset") and self.TIME_ZONE:
|
if hasattr(time, "tzset") and self.TIME_ZONE:
|
||||||
# When we can, attempt to validate the timezone. If we can't find
|
# When we can, attempt to validate the timezone. If we can't find
|
||||||
# this file, no check happens and it's harmless.
|
# this file, no check happens and it's harmless.
|
||||||
@ -241,6 +257,16 @@ class UserSettingsHolder:
|
|||||||
FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG,
|
FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG,
|
||||||
RemovedInDjango60Warning,
|
RemovedInDjango60Warning,
|
||||||
)
|
)
|
||||||
|
if name == "DEFAULT_TABLESPACE":
|
||||||
|
warnings.warn(
|
||||||
|
DEFAULT_TABLESPACE_DEPRECATED_MSG,
|
||||||
|
RemovedInDjango60Warning,
|
||||||
|
)
|
||||||
|
if name == "DEFAULT_INDEX_TABLESPACE":
|
||||||
|
warnings.warn(
|
||||||
|
DEFAULT_INDEX_TABLESPACE_DEPRECATED_MSG,
|
||||||
|
RemovedInDjango60Warning,
|
||||||
|
)
|
||||||
super().__setattr__(name, value)
|
super().__setattr__(name, value)
|
||||||
|
|
||||||
def __delattr__(self, name):
|
def __delattr__(self, name):
|
||||||
|
@ -3,8 +3,15 @@ from unittest import mock
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import connection, models
|
from django.db import connection, models
|
||||||
from django.db.models.functions import Lower, Upper
|
from django.db.models.functions import Lower, Upper
|
||||||
from django.test import SimpleTestCase, TestCase, override_settings, skipUnlessDBFeature
|
from django.test import (
|
||||||
|
SimpleTestCase,
|
||||||
|
TestCase,
|
||||||
|
ignore_warnings,
|
||||||
|
override_settings,
|
||||||
|
skipUnlessDBFeature,
|
||||||
|
)
|
||||||
from django.test.utils import isolate_apps
|
from django.test.utils import isolate_apps
|
||||||
|
from django.utils.deprecation import RemovedInDjango60Warning
|
||||||
|
|
||||||
from .models import Book, ChildModel1, ChildModel2
|
from .models import Book, ChildModel1, ChildModel2
|
||||||
|
|
||||||
@ -305,9 +312,10 @@ class SimpleIndexesTests(SimpleTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(DEFAULT_TABLESPACE=None)
|
@ignore_warnings(category=RemovedInDjango60Warning)
|
||||||
class IndexesTests(TestCase):
|
class IndexesTests(TestCase):
|
||||||
@skipUnlessDBFeature("supports_tablespaces")
|
@skipUnlessDBFeature("supports_tablespaces")
|
||||||
|
@override_settings(DEFAULT_TABLESPACE=None)
|
||||||
def test_db_tablespace(self):
|
def test_db_tablespace(self):
|
||||||
editor = connection.schema_editor()
|
editor = connection.schema_editor()
|
||||||
# Index with db_tablespace attribute.
|
# Index with db_tablespace attribute.
|
||||||
@ -346,6 +354,7 @@ class IndexesTests(TestCase):
|
|||||||
self.assertIn('"idx_tbls"', str(index.create_sql(Book, editor)).lower())
|
self.assertIn('"idx_tbls"', str(index.create_sql(Book, editor)).lower())
|
||||||
|
|
||||||
@skipUnlessDBFeature("supports_tablespaces")
|
@skipUnlessDBFeature("supports_tablespaces")
|
||||||
|
@override_settings(DEFAULT_TABLESPACE=None)
|
||||||
def test_func_with_tablespace(self):
|
def test_func_with_tablespace(self):
|
||||||
# Functional index with db_tablespace attribute.
|
# Functional index with db_tablespace attribute.
|
||||||
index = models.Index(
|
index = models.Index(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user