Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 32 additions & 29 deletions django/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.conf import global_settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import (
RemovedInDjango70Warning,
RemovedInDjango2028Warning,
warn_about_external_use,
)
from django.utils.functional import LazyObject, empty
Expand All @@ -25,20 +25,20 @@
DEFAULT_STORAGE_ALIAS = "default"
STATICFILES_STORAGE_ALIAS = "staticfiles"

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
SIGNED_COOKIE_LEGACY_SALT_DEPRECATED_MSG = (
"The SIGNED_COOKIE_LEGACY_SALT_FALLBACK transitional setting is "
"deprecated. Remove it from your settings once legacy signed cookies "
"have expired. They will not be accepted in Django 7.0."
"have expired. They will not be accepted in Django 2028."
)
# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
USE_BLANK_CHOICE_DASH_DEPRECATED_MSG = (
"The USE_BLANK_CHOICE_DASH setting is deprecated. If you wish to define "
"your own default blank choice label, override "
"django.db.models.fields.BLANK_CHOICE_LABEL in your app's ready() method."
)

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
DEPRECATED_EMAIL_SETTINGS = {
"EMAIL_BACKEND",
"EMAIL_FILE_PATH",
Expand All @@ -53,11 +53,11 @@
"EMAIL_USE_TLS",
}
EMAIL_SETTING_DEPRECATED_MSG = (
"The {name} setting is deprecated. Migrate to MAILERS before Django 7.0."
"The {name} setting is deprecated. Migrate to MAILERS before Django 2028."
)


# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
# Must be called with the complete set of user-defined setting names (but no
# default settings).
def _check_email_settings_conflicts(explicit_settings):
Expand Down Expand Up @@ -123,14 +123,15 @@ def __getattr__(self, name):
_wrapped = self._wrapped
val = getattr(_wrapped, name)

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
if name in DEPRECATED_EMAIL_SETTINGS:
if hasattr(_wrapped, "MAILERS"):
raise AttributeError(
f"The {name} setting is not available when MAILERS is defined."
)
_show_settings_deprecation_warning(
EMAIL_SETTING_DEPRECATED_MSG.format(name=name), RemovedInDjango70Warning
EMAIL_SETTING_DEPRECATED_MSG.format(name=name),
RemovedInDjango2028Warning,
)

# Special case some settings which require further modification.
Expand All @@ -154,26 +155,27 @@ def __setattr__(self, name, value):
else:
self.__dict__.pop(name, None)

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
if name == "SIGNED_COOKIE_LEGACY_SALT_FALLBACK":
_show_settings_deprecation_warning(
SIGNED_COOKIE_LEGACY_SALT_DEPRECATED_MSG,
RemovedInDjango70Warning,
RemovedInDjango2028Warning,
)
# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
if name == "USE_BLANK_CHOICE_DASH":
_show_settings_deprecation_warning(
USE_BLANK_CHOICE_DASH_DEPRECATED_MSG, RemovedInDjango70Warning
USE_BLANK_CHOICE_DASH_DEPRECATED_MSG, RemovedInDjango2028Warning
)
# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
if name == "MAILERS":
# When MAILERS is set, clear any cached values of
# deprecated settings so that __getattr__() runs again for them.
for setting in DEPRECATED_EMAIL_SETTINGS:
self.__dict__.pop(setting, None)
if name in DEPRECATED_EMAIL_SETTINGS:
_show_settings_deprecation_warning(
EMAIL_SETTING_DEPRECATED_MSG.format(name=name), RemovedInDjango70Warning
EMAIL_SETTING_DEPRECATED_MSG.format(name=name),
RemovedInDjango2028Warning,
)

super().__setattr__(name, value)
Expand All @@ -183,7 +185,7 @@ def __delattr__(self, name):
super().__delattr__(name)
self.__dict__.pop(name, None)

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
def __dir__(self):
attrs = super().__dir__()
if hasattr(self._wrapped, "MAILERS"):
Expand All @@ -206,7 +208,7 @@ def configure(self, default_settings=global_settings, **options):
if self._wrapped is not empty:
raise RuntimeError("Settings already configured.")

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
_check_email_settings_conflicts(options.keys())

holder = UserSettingsHolder(default_settings)
Expand Down Expand Up @@ -278,26 +280,26 @@ def __init__(self, settings_module):
setattr(self, setting, setting_value)
self._explicit_settings.add(setting)

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
if "SIGNED_COOKIE_LEGACY_SALT_FALLBACK" in self._explicit_settings:
warnings.warn(
SIGNED_COOKIE_LEGACY_SALT_DEPRECATED_MSG,
RemovedInDjango70Warning,
RemovedInDjango2028Warning,
skip_file_prefixes=django_file_prefixes(),
)
# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
if "USE_BLANK_CHOICE_DASH" in self._explicit_settings:
warnings.warn(
USE_BLANK_CHOICE_DASH_DEPRECATED_MSG,
RemovedInDjango70Warning,
RemovedInDjango2028Warning,
skip_file_prefixes=django_file_prefixes(),
)
# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
_check_email_settings_conflicts(self._explicit_settings)
for name in DEPRECATED_EMAIL_SETTINGS.intersection(self._explicit_settings):
warnings.warn(
EMAIL_SETTING_DEPRECATED_MSG.format(name=name),
RemovedInDjango70Warning,
RemovedInDjango2028Warning,
skip_file_prefixes=django_file_prefixes(),
)

Expand Down Expand Up @@ -343,21 +345,22 @@ def __getattr__(self, name):

def __setattr__(self, name, value):
self._deleted.discard(name)
# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
if name == "SIGNED_COOKIE_LEGACY_SALT_FALLBACK":
_show_settings_deprecation_warning(
SIGNED_COOKIE_LEGACY_SALT_DEPRECATED_MSG,
RemovedInDjango70Warning,
RemovedInDjango2028Warning,
)
# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
if name == "USE_BLANK_CHOICE_DASH":
_show_settings_deprecation_warning(
USE_BLANK_CHOICE_DASH_DEPRECATED_MSG, RemovedInDjango70Warning
USE_BLANK_CHOICE_DASH_DEPRECATED_MSG, RemovedInDjango2028Warning
)
# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
if name in DEPRECATED_EMAIL_SETTINGS:
_show_settings_deprecation_warning(
EMAIL_SETTING_DEPRECATED_MSG.format(name=name), RemovedInDjango70Warning
EMAIL_SETTING_DEPRECATED_MSG.format(name=name),
RemovedInDjango2028Warning,
)

super().__setattr__(name, value)
Expand Down
18 changes: 9 additions & 9 deletions django/conf/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,28 +188,28 @@ def gettext_noop(s):
DATABASE_ROUTERS = []

# Mailer configurations. No mailers are defined by default.
# RemovedInDjango70Warning: uncomment the next line.
# RemovedInDjango2028Warning: uncomment the next line.
# MAILERS = {}

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
# The email backend to use. For possible shortcuts see django.core.mail.
# The default is to use the SMTP backend.
# Third-party backends can be specified by providing a Python path
# to a module that defines an EmailBackend class.
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
# Host for sending email.
EMAIL_HOST = "localhost"

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
# Port for sending email.
EMAIL_PORT = 25

# Whether to send SMTP 'Date' header in the local time zone or in UTC.
EMAIL_USE_LOCALTIME = False

# RemovedInDjango70Warning.
# RemovedInDjango2028Warning.
# Optional SMTP authentication information for EMAIL_HOST.
EMAIL_HOST_USER = ""
EMAIL_HOST_PASSWORD = ""
Expand All @@ -226,7 +226,7 @@ def gettext_noop(s):

# Default form rendering class.
FORM_RENDERER = "django.forms.renderers.DjangoTemplates"
# RemovedInDjango70Warning: This setting allows to revert back to the old
# RemovedInDjango2028Warning: This setting allows to revert back to the old
# blank choice label in Django 6.1.
USE_BLANK_CHOICE_DASH = False

Expand Down Expand Up @@ -681,9 +681,9 @@ def gettext_noop(s):
SECURE_CSP = {}
SECURE_CSP_REPORT_ONLY = {}

# RemovedInDjango70Warning: A transitional setting helpful in early adoption of
# HTTPS as the default protocol in urlize and urlizetrunc when no protocol is
# provided. Set to True to assume HTTPS during the Django 6.x release cycle.
# RemovedInDjango2028Warning: A transitional setting helpful in early adoption
# of HTTPS as the default protocol in urlize and urlizetrunc when no protocol
# is provided. Set to True to assume HTTPS during the Django 6.x release cycle.
URLIZE_ASSUME_HTTPS = False

#########
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/admin/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ def _check_list_select_related(self, obj):

if not isinstance(obj.list_select_related, (bool, list, tuple)):
return must_be(
# RemovedInDjango70Warning: when the deprecation ends, replace:
# RemovedInDjango2028Warning: replace with:
# "a tuple, list, or False",
# and also update docs/ref/checks.txt.
"a boolean, tuple or list",
Expand Down
Loading
Loading