Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #21188 -- Introduced subclasses for to-be-removed-in-django-XX …

…warnings

Thanks Anssi Kääriäinen for the idea and Simon Charette for the
review.
  • Loading branch information...
commit 210d0489c5daad56b806f8165f9fe09fb3c2a019 1 parent 70ec4d7
@claudep claudep authored
Showing with 287 additions and 189 deletions.
  1. +10 −9 django/apps/registry.py
  2. +2 −1  django/conf/urls/shortcut.py
  3. +14 −13 django/contrib/admin/options.py
  4. +3 −1 django/contrib/admin/util.py
  5. +5 −5 django/contrib/admin/views/main.py
  6. +2 −1  django/contrib/admindocs/views.py
  7. +4 −1 django/contrib/comments/__init__.py
  8. +2 −2 django/contrib/comments/templatetags/comments.py
  9. +2 −2 django/contrib/contenttypes/fields.py
  10. +2 −1  django/contrib/contenttypes/generic.py
  11. +3 −1 django/contrib/gis/db/backends/util.py
  12. +3 −2 django/contrib/gis/sitemaps/views.py
  13. +4 −3 django/contrib/sites/models.py
  14. +2 −1  django/core/cache/__init__.py
  15. +2 −3 django/core/cache/backends/memcached.py
  16. +2 −1  django/core/handlers/wsgi.py
  17. +3 −2 django/core/management/base.py
  18. +2 −1  django/core/management/commands/dumpdata.py
  19. +2 −1  django/core/management/commands/runfcgi.py
  20. +3 −1 django/core/management/commands/syncdb.py
  21. +2 −1  django/core/management/commands/validate.py
  22. +2 −1  django/core/management/sql.py
  23. +2 −1  django/core/serializers/base.py
  24. +3 −2 django/db/__init__.py
  25. +1 −1  django/db/backends/__init__.py
  26. +2 −1  django/db/backends/creation.py
  27. +3 −1 django/db/backends/util.py
  28. +2 −1  django/db/models/__init__.py
  29. +5 −4 django/db/models/base.py
  30. +2 −1  django/db/models/fields/__init__.py
  31. +3 −3 django/db/models/fields/related.py
  32. +3 −1 django/db/models/loading.py
  33. +3 −3 django/db/models/manager.py
  34. +6 −5 django/db/models/options.py
  35. +6 −5 django/db/models/sql/query.py
  36. +3 −2 django/db/models/sql/where.py
  37. +8 −7 django/db/transaction.py
  38. +3 −2 django/db/utils.py
  39. +3 −2 django/forms/fields.py
  40. +4 −3 django/forms/forms.py
  41. +7 −5 django/forms/models.py
  42. +3 −1 django/forms/util.py
  43. +3 −2 django/forms/utils.py
  44. +4 −3 django/forms/widgets.py
  45. +2 −1  django/middleware/cache.py
  46. +2 −1  django/middleware/common.py
  47. +4 −1 django/middleware/doc.py
  48. +2 −1  django/middleware/transaction.py
  49. +3 −2 django/template/defaulttags.py
  50. +3 −2 django/templatetags/future.py
  51. +4 −2 django/test/_doctest.py
  52. +2 −1  django/test/simple.py
  53. +5 −7 django/test/utils.py
  54. +4 −2 django/utils/datastructures.py
  55. +8 −0 django/utils/deprecation.py
  56. +3 −1 django/utils/dictconfig.py
  57. +2 −1  django/utils/functional.py
  58. +4 −3 django/utils/html.py
  59. +2 −1  django/utils/image.py
  60. +3 −1 django/utils/importlib.py
  61. +2 −1  django/utils/module_loading.py
  62. +2 −1  django/utils/text.py
  63. +2 −1  django/utils/translation/trans_real.py
  64. +4 −3 django/utils/tzinfo.py
  65. +3 −1 django/utils/unittest.py
  66. +2 −1  django/views/defaults.py
  67. +3 −2 django/views/generic/edit.py
  68. +5 −5 docs/internals/contributing/writing-code/submitting-patches.txt
  69. +6 −7 docs/internals/release-process.txt
  70. +3 −2 tests/defaultfilters/tests.py
  71. +1 −0  tests/deprecation/tests.py
  72. +3 −2 tests/forms_tests/tests/test_widgets.py
  73. +4 −3 tests/generic_views/test_edit.py
  74. +2 −1  tests/httpwrappers/tests.py
  75. +4 −3 tests/middleware/tests.py
  76. +4 −3 tests/model_forms/tests.py
  77. +4 −3 tests/model_forms_regress/tests.py
  78. +2 −1  tests/modeladmin/tests.py
  79. +8 −3 tests/runtests.py
  80. +3 −2 tests/template_tests/tests.py
  81. +3 −2 tests/utils_tests/test_html.py
  82. +3 −2 tests/utils_tests/test_module_loading.py
  83. +3 −2 tests/utils_tests/test_text.py
  84. +3 −1 tests/utils_tests/test_tzinfo.py
View
19 django/apps/registry.py
@@ -6,6 +6,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.utils import lru_cache
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils._os import upath
from .config import AppConfig
@@ -156,7 +157,7 @@ def get_models(self, app_mod=None, include_auto_created=False,
if app_mod:
warnings.warn(
"The app_mod argument of get_models is deprecated.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
app_label = app_mod.__name__.split('.')[-2]
try:
return list(self.get_app_config(app_label).get_models(
@@ -328,7 +329,7 @@ def load_app(self, app_name):
"""
warnings.warn(
"load_app(app_name) is deprecated.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
app_config = AppConfig.create(app_name)
app_config.import_models(self.all_models[app_config.label])
self.app_configs[app_config.label] = app_config
@@ -338,7 +339,7 @@ def load_app(self, app_name):
def app_cache_ready(self):
warnings.warn(
"app_cache_ready() is deprecated in favor of the ready property.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
return self.ready
def get_app(self, app_label):
@@ -347,7 +348,7 @@ def get_app(self, app_label):
"""
warnings.warn(
"get_app_config(app_label).models_module supersedes get_app(app_label).",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
try:
models_module = self.get_app_config(app_label).models_module
except LookupError as exc:
@@ -364,7 +365,7 @@ def get_apps(self):
"""
warnings.warn(
"[a.models_module for a in get_app_configs()] supersedes get_apps().",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
app_configs = self.get_app_configs()
return [app_config.models_module for app_config in app_configs
if app_config.models_module is not None]
@@ -375,7 +376,7 @@ def _get_app_package(self, app):
def get_app_package(self, app_label):
warnings.warn(
"get_app_config(label).name supersedes get_app_package(label).",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
return self._get_app_package(self.get_app(app_label))
def _get_app_path(self, app):
@@ -388,7 +389,7 @@ def _get_app_path(self, app):
def get_app_path(self, app_label):
warnings.warn(
"get_app_config(label).path supersedes get_app_path(label).",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
return self._get_app_path(self.get_app(app_label))
def get_app_paths(self):
@@ -400,7 +401,7 @@ def get_app_paths(self):
"""
warnings.warn(
"[a.path for a in get_app_configs()] supersedes get_app_paths().",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
self.check_ready()
app_paths = []
for app in self.get_apps():
@@ -413,7 +414,7 @@ def register_models(self, app_label, *models):
"""
warnings.warn(
"register_models(app_label, *models) is deprecated.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
for model in models:
self.register_model(app_label, model)
View
3  django/conf/urls/shortcut.py
@@ -1,9 +1,10 @@
import warnings
from django.conf.urls import patterns
+from django.utils.deprecation import RemovedInDjango18Warning
warnings.warn("django.conf.urls.shortcut will be removed in Django 1.8.",
- DeprecationWarning)
+ RemovedInDjango18Warning)
urlpatterns = patterns('django.views',
(r'^(?P<content_type_id>\d+)/(?P<object_id>.*)/$', 'defaults.shortcut'),
View
27 django/contrib/admin/options.py
@@ -18,7 +18,8 @@
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.contrib.auth import get_permission_codename
from django.core import checks
-from django.core.exceptions import PermissionDenied, ValidationError, FieldError, ImproperlyConfigured
+from django.core.exceptions import (PermissionDenied, ValidationError,
+ FieldError, ImproperlyConfigured)
from django.core.paginator import Paginator
from django.core.urlresolvers import reverse
from django.db import models, transaction, router
@@ -35,9 +36,9 @@
from django.template.response import SimpleTemplateResponse, TemplateResponse
from django.utils import six
from django.utils.decorators import method_decorator
-from django.utils.deprecation import RenameMethodsBase
-from django.utils.encoding import force_text
-from django.utils.encoding import python_2_unicode_compatible
+from django.utils.deprecation import (RenameMethodsBase,
+ RemovedInDjango18Warning, RemovedInDjango19Warning)
+from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import escape, escapejs
from django.utils.http import urlencode
from django.utils.text import capfirst, get_text_list
@@ -93,7 +94,7 @@ class IncorrectLookupParameters(Exception):
class RenameBaseModelAdminMethods(forms.MediaDefiningClass, RenameMethodsBase):
renamed_methods = (
- ('queryset', 'get_queryset', DeprecationWarning),
+ ('queryset', 'get_queryset', RemovedInDjango18Warning),
)
@@ -125,7 +126,7 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)):
def validate(cls, model):
warnings.warn(
'ModelAdmin.validate() is deprecated. Use "check()" instead.',
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
if cls.validator_class:
validator = cls.validator_class()
else:
@@ -139,7 +140,7 @@ def check(cls, model, **kwargs):
'ModelAdmin.validator_class is deprecated. '
'ModeAdmin validators must be converted to use '
'the system check framework.',
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
validator = cls.validator_class()
try:
validator.validate(cls, model)
@@ -306,7 +307,7 @@ def declared_fieldsets(self):
warnings.warn(
"ModelAdmin.declared_fieldsets is deprecated and "
"will be removed in Django 1.9.",
- PendingDeprecationWarning, stacklevel=2
+ RemovedInDjango19Warning, stacklevel=2
)
if self.fieldsets:
@@ -332,11 +333,11 @@ def get_fieldsets(self, request, obj=None):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
declared_fieldsets = self.declared_fieldsets
- if len(w) != 1 or not issubclass(w[0].category, PendingDeprecationWarning):
+ if len(w) != 1 or not issubclass(w[0].category, RemovedInDjango19Warning):
warnings.warn(
"ModelAdmin.declared_fieldsets is deprecated and "
"will be removed in Django 1.9.",
- PendingDeprecationWarning
+ RemovedInDjango19Warning
)
if declared_fieldsets:
return declared_fieldsets
@@ -695,7 +696,7 @@ def get_formsets(self, request, obj=None):
warnings.warn(
"ModelAdmin.get_formsets() is deprecated and will be removed in "
"Django 1.9. Use ModelAdmin.get_formsets_with_inlines() instead.",
- PendingDeprecationWarning, stacklevel=2
+ RemovedInDjango19Warning, stacklevel=2
)
return self._get_formsets(request, obj)
@@ -711,11 +712,11 @@ def get_formsets_with_inlines(self, request, obj=None):
warnings.simplefilter("always")
formsets = self.get_formsets(request, obj)
- if len(w) != 1 or not issubclass(w[0].category, PendingDeprecationWarning):
+ if len(w) != 1 or not issubclass(w[0].category, RemovedInDjango19Warning):
warnings.warn(
"ModelAdmin.get_formsets() is deprecated and will be removed in "
"Django 1.9. Use ModelAdmin.get_formsets_with_inlines() instead.",
- PendingDeprecationWarning
+ RemovedInDjango19Warning
)
if formsets:
zipped = zip(formsets, self.get_inline_instances(request, None))
View
4 django/contrib/admin/util.py
@@ -1,7 +1,9 @@
import warnings
+from django.utils.deprecation import RemovedInDjango19Warning
+
warnings.warn(
"The django.contrib.admin.util module has been renamed. "
- "Use django.contrib.admin.utils instead.", PendingDeprecationWarning)
+ "Use django.contrib.admin.utils instead.", RemovedInDjango19Warning)
from django.contrib.admin.utils import * # NOQA
View
10 django/contrib/admin/views/main.py
@@ -8,7 +8,7 @@
from django.db import models
from django.db.models.fields import FieldDoesNotExist
from django.utils import six
-from django.utils.deprecation import RenameMethodsBase
+from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.encoding import force_text
from django.utils.translation import ugettext, ugettext_lazy
from django.utils.http import urlencode
@@ -51,7 +51,7 @@ def _is_changelist_popup(request):
warnings.warn(
"The `%s` GET parameter has been renamed to `%s`." %
(IS_LEGACY_POPUP_VAR, IS_POPUP_VAR),
- DeprecationWarning, 2)
+ RemovedInDjango18Warning, 2)
return True
return False
@@ -59,7 +59,7 @@ def _is_changelist_popup(request):
class RenameChangeListMethods(RenameMethodsBase):
renamed_methods = (
- ('get_query_set', 'get_queryset', DeprecationWarning),
+ ('get_query_set', 'get_queryset', RemovedInDjango18Warning),
)
@@ -114,14 +114,14 @@ def __init__(self, request, model, list_display, list_display_links,
def root_query_set(self):
warnings.warn("`ChangeList.root_query_set` is deprecated, "
"use `root_queryset` instead.",
- DeprecationWarning, 2)
+ RemovedInDjango18Warning, 2)
return self.root_queryset
@property
def query_set(self):
warnings.warn("`ChangeList.query_set` is deprecated, "
"use `queryset` instead.",
- DeprecationWarning, 2)
+ RemovedInDjango18Warning, 2)
return self.queryset
def get_filters_params(self, params=None):
View
3  django/contrib/admindocs/views.py
@@ -15,6 +15,7 @@
from django.core import urlresolvers
from django.contrib.admindocs import utils
from django.utils.decorators import method_decorator
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils._os import upath
from django.utils import six
from django.utils.translation import ugettext as _
@@ -25,7 +26,7 @@
if getattr(settings, 'ADMIN_FOR', None):
warnings.warn('The ADMIN_FOR setting has been removed, you can remove '
- 'this setting from your configuration.', DeprecationWarning,
+ 'this setting from your configuration.', RemovedInDjango18Warning,
stacklevel=2)
View
5 django/contrib/comments/__init__.py
@@ -1,13 +1,16 @@
from importlib import import_module
import warnings
+
from django.apps import apps as django_apps
from django.conf import settings
from django.core import urlresolvers
from django.core.exceptions import ImproperlyConfigured
from django.contrib.comments.models import Comment
from django.contrib.comments.forms import CommentForm
+from django.utils.deprecation import RemovedInDjango18Warning
+
-warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", DeprecationWarning)
+warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", RemovedInDjango18Warning)
DEFAULT_COMMENTS_APP = 'django.contrib.comments'
View
4 django/contrib/comments/templatetags/comments.py
@@ -4,7 +4,7 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib import comments
from django.utils import six
-from django.utils.deprecation import RenameMethodsBase
+from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.encoding import smart_text
register = template.Library()
@@ -12,7 +12,7 @@
class RenameBaseCommentNodeMethods(RenameMethodsBase):
renamed_methods = (
- ('get_query_set', 'get_queryset', DeprecationWarning),
+ ('get_query_set', 'get_queryset', RemovedInDjango18Warning),
)
View
4 django/contrib/contenttypes/fields.py
@@ -13,13 +13,13 @@
from django.db.models.sql.datastructures import Col
from django.contrib.contenttypes.models import ContentType
from django.utils import six
-from django.utils.deprecation import RenameMethodsBase
+from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.encoding import smart_text, python_2_unicode_compatible
class RenameGenericForeignKeyMethods(RenameMethodsBase):
renamed_methods = (
- ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
+ ('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning),
)
View
3  django/contrib/contenttypes/generic.py
@@ -2,11 +2,12 @@
import warnings
+from django.utils.deprecation import RemovedInDjango19Warning
warnings.warn(
('django.contrib.contenttypes.generic is deprecated and will be removed in '
'Django 1.9. Its contents have been moved to the fields, forms, and admin '
- 'submodules of django.contrib.contenttypes.'), PendingDeprecationWarning, stacklevel=2
+ 'submodules of django.contrib.contenttypes.'), RemovedInDjango19Warning, stacklevel=2
)
from django.contrib.contenttypes.admin import ( # NOQA
View
4 django/contrib/gis/db/backends/util.py
@@ -1,7 +1,9 @@
import warnings
+from django.utils.deprecation import RemovedInDjango19Warning
+
warnings.warn(
"The django.contrib.gis.db.backends.util module has been renamed. "
- "Use django.contrib.gis.db.backends.utils instead.", PendingDeprecationWarning)
+ "Use django.contrib.gis.db.backends.utils instead.", RemovedInDjango19Warning)
from django.contrib.gis.db.backends.utils import * # NOQA
View
5 django/contrib/gis/sitemaps/views.py
@@ -12,6 +12,7 @@
from django.db import connections, DEFAULT_DB_ALIAS
from django.db.models.fields import FieldDoesNotExist
from django.utils import six
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.translation import ugettext as _
from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz
@@ -23,7 +24,7 @@ def index(request, sitemaps):
for resolving geographic section sitemap URLs.
"""
warnings.warn("Geo Sitemaps are deprecated. Use plain sitemaps from "
- "django.contrib.sitemaps instead", DeprecationWarning, stacklevel=2)
+ "django.contrib.sitemaps instead", RemovedInDjango18Warning, stacklevel=2)
current_site = get_current_site(request)
sites = []
protocol = request.scheme
@@ -48,7 +49,7 @@ def sitemap(request, sitemaps, section=None):
elements defined by Google.
"""
warnings.warn("Geo Sitemaps are deprecated. Use plain sitemaps from "
- "django.contrib.sitemaps instead", DeprecationWarning, stacklevel=2)
+ "django.contrib.sitemaps instead", RemovedInDjango18Warning, stacklevel=2)
maps, urls = [], []
if section is not None:
if section not in sitemaps:
View
7 django/contrib/sites/models.py
@@ -6,8 +6,9 @@
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.db import models
from django.db.models.signals import pre_save, pre_delete
-from django.utils.translation import ugettext_lazy as _
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import python_2_unicode_compatible
+from django.utils.translation import ugettext_lazy as _
from .requests import RequestSite as RealRequestSite
from .shortcuts import get_current_site as real_get_current_site
@@ -82,14 +83,14 @@ class RequestSite(RealRequestSite):
def __init__(self, *args, **kwargs):
warnings.warn(
"Please import RequestSite from django.contrib.sites.requests.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
super(RequestSite, self).__init__(*args, **kwargs)
def get_current_site(request):
warnings.warn(
"Please import get_current_site from django.contrib.sites.shortcuts.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
return real_get_current_site(request)
View
3  django/core/cache/__init__.py
@@ -20,6 +20,7 @@
from django.core.cache.backends.base import (
InvalidCacheBackendError, CacheKeyWarning, BaseCache)
from django.core.exceptions import ImproperlyConfigured
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.module_loading import import_string
@@ -52,7 +53,7 @@ def get_cache(backend, **kwargs):
"""
warnings.warn("'get_cache' is deprecated in favor of 'caches'.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
cache = _create_cache(backend, **kwargs)
# Some caches -- python-memcached in particular -- need to do a cleanup at the
# end of a request cycle. If not implemented in a particular backend
View
5 django/core/cache/backends/memcached.py
@@ -4,16 +4,15 @@
import pickle
from django.core.cache.backends.base import BaseCache, DEFAULT_TIMEOUT
-
from django.utils import six
-from django.utils.deprecation import RenameMethodsBase
+from django.utils.deprecation import RenameMethodsBase, RemovedInDjango19Warning
from django.utils.encoding import force_str
from django.utils.functional import cached_property
class BaseMemcachedCacheMethods(RenameMethodsBase):
renamed_methods = (
- ('_get_memcache_timeout', 'get_backend_timeout', PendingDeprecationWarning),
+ ('_get_memcache_timeout', 'get_backend_timeout', RemovedInDjango19Warning),
)
View
3  django/core/handlers/wsgi.py
@@ -14,6 +14,7 @@
from django.core.handlers import base
from django.core.urlresolvers import set_script_prefix
from django.utils import datastructures
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_str, force_text
from django.utils.functional import cached_property
from django.utils import six
@@ -118,7 +119,7 @@ def _get_scheme(self):
def _get_request(self):
warnings.warn('`request.REQUEST` is deprecated, use `request.GET` or '
- '`request.POST` instead.', PendingDeprecationWarning, 2)
+ '`request.POST` instead.', RemovedInDjango19Warning, 2)
if not hasattr(self, '_request'):
self._request = datastructures.MergeDict(self.POST, self.GET)
return self._request
View
5 django/core/management/base.py
@@ -17,6 +17,7 @@
from django.core import checks
from django.core.exceptions import ImproperlyConfigured
from django.core.management.color import color_style, no_style
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_str
@@ -219,7 +220,7 @@ def __init__(self):
warnings.warn(
'"requires_model_validation" is deprecated '
'in favor of "requires_system_checks".',
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
if has_old_option and has_new_option:
raise ImproperlyConfigured(
'Command %s defines both "requires_model_validation" '
@@ -467,7 +468,7 @@ def handle_app_config(self, app_config, **options):
warnings.warn(
"AppCommand.handle_app() is superseded by "
"AppCommand.handle_app_config().",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
if app_config.models_module is None:
raise CommandError(
"AppCommand cannot handle app '%s' in legacy mode "
View
3  django/core/management/commands/dumpdata.py
@@ -7,6 +7,7 @@
from django.core.management.base import BaseCommand, CommandError
from django.core import serializers
from django.db import router, DEFAULT_DB_ALIAS
+from django.utils.deprecation import RemovedInDjango19Warning
class Command(BaseCommand):
@@ -50,7 +51,7 @@ def handle(self, *app_labels, **options):
use_natural_keys = options.get('use_natural_keys')
if use_natural_keys:
warnings.warn("``--natural`` is deprecated; use ``--natural-foreign`` instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
use_natural_foreign_keys = options.get('use_natural_foreign_keys') or use_natural_keys
use_natural_primary_keys = options.get('use_natural_primary_keys')
use_base_manager = options.get('use_base_manager')
View
3  django/core/management/commands/runfcgi.py
@@ -1,6 +1,7 @@
import warnings
from django.core.management.base import BaseCommand
+from django.utils.deprecation import RemovedInDjango19Warning
class Command(BaseCommand):
@@ -10,7 +11,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
warnings.warn(
"FastCGI support has been deprecated and will be removed in Django 1.9.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
from django.conf import settings
from django.utils import translation
View
4 django/core/management/commands/syncdb.py
@@ -1,8 +1,10 @@
import warnings
from optparse import make_option
+
from django.db import DEFAULT_DB_ALIAS
from django.core.management import call_command
from django.core.management.base import NoArgsCommand
+from django.utils.deprecation import RemovedInDjango19Warning
class Command(NoArgsCommand):
@@ -18,5 +20,5 @@ class Command(NoArgsCommand):
help = "Deprecated - use 'migrate' instead."
def handle_noargs(self, **options):
- warnings.warn("The syncdb command will be removed in Django 1.9", PendingDeprecationWarning)
+ warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning)
call_command("migrate", **options)
View
3  django/core/management/commands/validate.py
@@ -4,6 +4,7 @@
import warnings
from django.core.management.commands.check import Command as CheckCommand
+from django.utils.deprecation import RemovedInDjango19Warning
class Command(CheckCommand):
@@ -11,5 +12,5 @@ class Command(CheckCommand):
def handle_noargs(self, **options):
warnings.warn('"validate" has been deprecated in favor of "check".',
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
super(Command, self).handle_noargs(**options)
View
3  django/core/management/sql.py
@@ -10,6 +10,7 @@
from django.core.management.base import CommandError
from django.db import models, router
from django.utils import six
+from django.utils.deprecation import RemovedInDjango19Warning
def sql_create(app_config, style, connection):
@@ -179,7 +180,7 @@ def custom_sql_for_model(model, style, connection):
if os.path.exists(old_app_dir):
warnings.warn("Custom SQL location '<app_label>/models/sql' is "
"deprecated, use '<app_label>/sql' instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
app_dirs.append(old_app_dir)
output = []
View
3  django/core/serializers/base.py
@@ -5,6 +5,7 @@
from django.db import models
from django.utils import six
+from django.utils.deprecation import RemovedInDjango19Warning
class SerializerDoesNotExist(KeyError):
@@ -42,7 +43,7 @@ def serialize(self, queryset, **options):
self.use_natural_keys = options.pop("use_natural_keys", False)
if self.use_natural_keys:
warnings.warn("``use_natural_keys`` is deprecated; use ``use_natural_foreign_keys`` instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
self.use_natural_foreign_keys = options.pop('use_natural_foreign_keys', False) or self.use_natural_keys
self.use_natural_primary_keys = options.pop('use_natural_primary_keys', False)
View
5 django/db/__init__.py
@@ -5,6 +5,7 @@
IntegrityError, InternalError, ProgrammingError, NotSupportedError,
DatabaseError, InterfaceError, Error, load_backend,
ConnectionHandler, ConnectionRouter)
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.functional import cached_property
@@ -61,7 +62,7 @@ class DefaultBackendProxy(object):
@cached_property
def _backend(self):
warnings.warn("Accessing django.db.backend is deprecated.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
return load_backend(connections[DEFAULT_DB_ALIAS].settings_dict['ENGINE'])
def __getattr__(self, item):
@@ -79,7 +80,7 @@ def __delattr__(self, name):
def close_connection(**kwargs):
warnings.warn(
"close_connection is superseded by close_old_connections.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
# Avoid circular imports
from django.db import transaction
for conn in connections:
View
2  django/db/backends/__init__.py
@@ -1402,7 +1402,7 @@ def validate_field(self, errors, opts, f):
# This is deliberately commented out. It exists as a marker to
# remind us to remove this method, and the check_field() shim,
# when the time comes.
- # warnings.warn('"validate_field" has been deprecated", PendingDeprecationWarning)
+ # warnings.warn('"validate_field" has been deprecated", RemovedInDjango19Warning)
pass
def check_field(self, field, **kwargs):
View
3  django/db/backends/creation.py
@@ -5,6 +5,7 @@
from django.conf import settings
from django.db.utils import load_backend
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_bytes
from django.utils.functional import cached_property
from django.utils.six.moves import input
@@ -474,7 +475,7 @@ def set_autocommit(self):
"""
warnings.warn(
"set_autocommit was moved from BaseDatabaseCreation to "
- "BaseDatabaseWrapper.", DeprecationWarning, stacklevel=2)
+ "BaseDatabaseWrapper.", RemovedInDjango18Warning, stacklevel=2)
return self.connection.set_autocommit(True)
def sql_table_creation_suffix(self):
View
4 django/db/backends/util.py
@@ -1,7 +1,9 @@
import warnings
+from django.utils.deprecation import RemovedInDjango19Warning
+
warnings.warn(
"The django.db.backends.util module has been renamed. "
- "Use django.db.backends.utils instead.", PendingDeprecationWarning)
+ "Use django.db.backends.utils instead.", RemovedInDjango19Warning)
from django.db.backends.utils import * # NOQA
View
3  django/db/models/__init__.py
@@ -19,6 +19,7 @@
CASCADE, PROTECT, SET, SET_NULL, SET_DEFAULT, DO_NOTHING, ProtectedError)
from django.db.models.lookups import Lookup, Transform # NOQA
from django.db.models import signals # NOQA
+from django.utils.deprecation import RemovedInDjango19Warning
def permalink(func):
@@ -47,7 +48,7 @@ def make_alias(function_name):
def alias(*args, **kwargs):
warnings.warn(
"django.db.models.%s is deprecated." % function_name,
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
# This raises a second warning.
from . import loading
return getattr(loading, function_name)(*args, **kwargs)
View
9 django/db/models/base.py
@@ -22,12 +22,13 @@
from django.db.models.deletion import Collector
from django.db.models.options import Options
from django.db.models import signals
-from django.utils.translation import ugettext_lazy as _
-from django.utils.functional import curry
-from django.utils.encoding import force_str, force_text
from django.utils import six
+from django.utils.deprecation import RemovedInDjango19Warning
+from django.utils.encoding import force_str, force_text
+from django.utils.functional import curry
from django.utils.six.moves import zip
from django.utils.text import get_text_list, capfirst
+from django.utils.translation import ugettext_lazy as _
def subclass_exception(name, parents, module, attached_to=None):
@@ -114,7 +115,7 @@ def __new__(cls, name, bases, attrs):
msg += "Its app_label will be set to None in Django 1.9."
else:
msg += "This will no longer be supported in Django 1.9."
- warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
+ warnings.warn(msg, RemovedInDjango19Warning, stacklevel=2)
model_module = sys.modules[new_class.__module__]
package_components = model_module.__name__.split('.')
View
3  django/db/models/fields/__init__.py
@@ -19,6 +19,7 @@
from django.core import exceptions, validators, checks
from django.utils.datastructures import DictWrapper
from django.utils.dateparse import parse_date, parse_datetime, parse_time
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.functional import curry, total_ordering, Promise
from django.utils.text import capfirst
from django.utils import timezone
@@ -1618,7 +1619,7 @@ class IPAddressField(Field):
def __init__(self, *args, **kwargs):
warnings.warn("IPAddressField has been deprecated. Use GenericIPAddressField instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
kwargs['max_length'] = 15
super(IPAddressField, self).__init__(*args, **kwargs)
View
6 django/db/models/fields/related.py
@@ -14,7 +14,7 @@
from django.db.models.sql.datastructures import Col
from django.utils.encoding import smart_text
from django.utils import six
-from django.utils.deprecation import RenameMethodsBase
+from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.translation import ugettext_lazy as _
from django.utils.functional import curry, cached_property
from django.core import exceptions
@@ -346,8 +346,8 @@ def related_query_name(self):
class RenameRelatedObjectDescriptorMethods(RenameMethodsBase):
renamed_methods = (
- ('get_query_set', 'get_queryset', DeprecationWarning),
- ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
+ ('get_query_set', 'get_queryset', RemovedInDjango18Warning),
+ ('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning),
)
View
4 django/db/models/loading.py
@@ -1,11 +1,13 @@
import warnings
from django.apps import apps
+from django.utils.deprecation import RemovedInDjango19Warning
+
warnings.warn(
"The utilities in django.db.models.loading are deprecated "
"in favor of the new application loading system.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
__all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models',
'load_app', 'app_cache_ready')
View
6 django/db/models/manager.py
@@ -6,7 +6,7 @@
from django.db.models import signals
from django.db.models.fields import FieldDoesNotExist
from django.utils import six
-from django.utils.deprecation import RenameMethodsBase
+from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.encoding import python_2_unicode_compatible
@@ -54,8 +54,8 @@ def ensure_default_manager(sender, **kwargs):
class RenameManagerMethods(RenameMethodsBase):
renamed_methods = (
- ('get_query_set', 'get_queryset', DeprecationWarning),
- ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
+ ('get_query_set', 'get_queryset', RemovedInDjango18Warning),
+ ('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning),
)
View
11 django/db/models/options.py
@@ -10,8 +10,9 @@
from django.db.models.fields import AutoField, FieldDoesNotExist
from django.db.models.fields.proxy import OrderWrt
from django.utils import six
-from django.utils.functional import cached_property
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text, smart_text, python_2_unicode_compatible
+from django.utils.functional import cached_property
from django.utils.text import camel_case_to_spaces
from django.utils.translation import activate, deactivate_all, get_language, string_concat
@@ -171,7 +172,7 @@ def module_name(self):
"""
warnings.warn(
"Options.module_name has been deprecated in favor of model_name",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
return self.model_name
def _prepare(self, model):
@@ -462,7 +463,7 @@ def get_add_permission(self):
warnings.warn(
"`Options.get_add_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
return 'add_%s' % self.model_name
def get_change_permission(self):
@@ -473,7 +474,7 @@ def get_change_permission(self):
warnings.warn(
"`Options.get_change_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
return 'change_%s' % self.model_name
def get_delete_permission(self):
@@ -484,7 +485,7 @@ def get_delete_permission(self):
warnings.warn(
"`Options.get_delete_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
return 'delete_%s' % self.model_name
def get_all_related_objects(self, local_only=False, include_hidden=False,
View
11 django/db/models/sql/query.py
@@ -11,9 +11,7 @@
import copy
import warnings
-from django.utils.encoding import force_text
-from django.utils.tree import Node
-from django.utils import six
+from django.core.exceptions import FieldError
from django.db import connections, DEFAULT_DB_ALIAS
from django.db.models.constants import LOOKUP_SEP
from django.db.models.aggregates import refs_aggregate
@@ -29,7 +27,10 @@
from django.db.models.sql.expressions import SQLEvaluator
from django.db.models.sql.where import (WhereNode, Constraint, EverythingNode,
ExtraWhere, AND, OR, EmptyWhere)
-from django.core.exceptions import FieldError
+from django.utils import six
+from django.utils.deprecation import RemovedInDjango19Warning
+from django.utils.encoding import force_text
+from django.utils.tree import Node
__all__ = ['Query', 'RawQuery']
@@ -1043,7 +1044,7 @@ def prepare_lookup_value(self, value, lookups, can_reuse):
elif callable(value):
warnings.warn(
"Passing callable arguments to queryset is deprecated.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
value = value()
elif isinstance(value, ExpressionNode):
# If value is a query expression, evaluate it
View
5 django/db/models/sql/where.py
@@ -11,6 +11,7 @@
from django.db.models.fields import DateTimeField, Field
from django.db.models.sql.datastructures import EmptyResultSet, Empty
from django.db.models.sql.aggregates import Aggregate
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.six.moves import xrange
from django.utils import timezone
from django.utils import tree
@@ -177,7 +178,7 @@ def make_atom(self, child, qn, connection):
"""
warnings.warn(
"The make_atom() method will be removed in Django 1.9. Use Lookup class instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
lvalue, lookup_type, value_annotation, params_or_value = child
field_internal_type = lvalue.field.get_internal_type() if lvalue.field else None
@@ -355,7 +356,7 @@ class Constraint(object):
def __init__(self, alias, col, field):
warnings.warn(
"The Constraint class will be removed in Django 1.9. Use Lookup class instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
self.alias, self.col, self.field = alias, col, field
def prepare(self, lookup_type, value):
View
15 django/db/transaction.py
@@ -20,6 +20,7 @@
connections, DEFAULT_DB_ALIAS,
DatabaseError, ProgrammingError)
from django.utils.decorators import available_attrs
+from django.utils.deprecation import RemovedInDjango18Warning
class TransactionManagementError(ProgrammingError):
@@ -110,22 +111,22 @@ def set_clean(using=None):
def is_managed(using=None):
warnings.warn("'is_managed' is deprecated.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
def managed(flag=True, using=None):
warnings.warn("'managed' no longer serves a purpose.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
def commit_unless_managed(using=None):
warnings.warn("'commit_unless_managed' is now a no-op.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
def rollback_unless_managed(using=None):
warnings.warn("'rollback_unless_managed' is now a no-op.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
###############
@@ -450,7 +451,7 @@ def autocommit(using=None):
your settings file and want the default behavior in some view functions.
"""
warnings.warn("autocommit is deprecated in favor of set_autocommit.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
def entering(using):
enter_transaction_management(managed=False, using=using)
@@ -469,7 +470,7 @@ def commit_on_success(using=None):
control in Web apps.
"""
warnings.warn("commit_on_success is deprecated in favor of atomic.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
def entering(using):
enter_transaction_management(using=using)
@@ -500,7 +501,7 @@ def commit_manually(using=None):
themselves.
"""
warnings.warn("commit_manually is deprecated in favor of set_autocommit.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
def entering(using):
enter_transaction_management(using=using)
View
5 django/db/utils.py
@@ -6,6 +6,7 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
+from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
from django.utils._os import upath
@@ -169,7 +170,7 @@ def ensure_defaults(self, alias):
if settings.TRANSACTIONS_MANAGED:
warnings.warn(
"TRANSACTIONS_MANAGED is deprecated. Use AUTOCOMMIT instead.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
conn.setdefault('AUTOCOMMIT', False)
conn.setdefault('AUTOCOMMIT', True)
conn.setdefault('ENGINE', 'django.db.backends.dummy')
@@ -272,7 +273,7 @@ def allow_migrate(self, db, model):
warnings.warn(
'Router.allow_syncdb has been deprecated and will stop working in Django 1.9. '
'Rename the method to allow_migrate.',
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
except AttributeError:
# If the router doesn't have a method, skip to the next one.
pass
View
5 django/forms/fields.py
@@ -25,6 +25,7 @@
from django.utils import formats
from django.utils.encoding import smart_text, force_str, force_text
from django.utils.ipv6 import clean_ipv6_address
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils import six
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
from django.utils.translation import ugettext_lazy as _, ungettext_lazy
@@ -502,7 +503,7 @@ def to_python(self, value):
warnings.warn(
'Using SplitDateTimeWidget with DateTimeField is deprecated. '
'Use SplitDateTimeField instead.',
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
if len(value) != 2:
raise ValidationError(self.error_messages['invalid'], code='invalid')
if value[0] in self.empty_values and value[1] in self.empty_values:
@@ -1169,7 +1170,7 @@ class IPAddressField(CharField):
def __init__(self, *args, **kwargs):
warnings.warn("IPAddressField has been deprecated. Use GenericIPAddressField instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
super(IPAddressField, self).__init__(*args, **kwargs)
def to_python(self, value):
View
7 django/forms/forms.py
@@ -12,8 +12,9 @@
from django.forms.fields import Field, FileField
from django.forms.utils import flatatt, ErrorDict, ErrorList
from django.forms.widgets import Media, MediaDefiningClass, TextInput, Textarea
-from django.utils.html import conditional_escape, format_html
+from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning
from django.utils.encoding import smart_text, force_text, python_2_unicode_compatible
+from django.utils.html import conditional_escape, format_html
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
from django.utils import six
@@ -43,7 +44,7 @@ def get_declared_fields(bases, attrs, with_base_fields=True):
warnings.warn(
"get_declared_fields is deprecated and will be removed in Django 1.9.",
- PendingDeprecationWarning,
+ RemovedInDjango19Warning,
stacklevel=2,
)
@@ -431,7 +432,7 @@ def changed_data(self):
if hasattr(field.widget, '_has_changed'):
warnings.warn("The _has_changed method on widgets is deprecated,"
" define it at field level instead.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
if field.widget._has_changed(initial_value, data_value):
self._changed_data.append(name)
elif field._has_changed(initial_value, data_value):
View
12 django/forms/models.py
@@ -8,15 +8,17 @@
from collections import OrderedDict
import warnings
-from django.core.exceptions import ValidationError, NON_FIELD_ERRORS, FieldError
+from django.core.exceptions import (
+ ValidationError, NON_FIELD_ERRORS, FieldError)
from django.forms.fields import Field, ChoiceField
from django.forms.forms import DeclarativeFieldsMetaclass, BaseForm
from django.forms.formsets import BaseFormSet, formset_factory
from django.forms.utils import ErrorList
from django.forms.widgets import (SelectMultiple, HiddenInput,
MultipleHiddenInput, CheckboxSelectMultiple)
-from django.utils.encoding import smart_text, force_text
from django.utils import six
+from django.utils.deprecation import RemovedInDjango18Warning
+from django.utils.encoding import smart_text, force_text
from django.utils.text import get_text_list, capfirst
from django.utils.translation import ugettext_lazy as _, ugettext, string_concat
@@ -269,7 +271,7 @@ def __new__(mcs, name, bases, attrs):
warnings.warn("Creating a ModelForm without either the 'fields' attribute "
"or the 'exclude' attribute is deprecated - form %s "
"needs updating" % name,
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
if opts.fields == ALL_FIELDS:
# Sentinel for fields_for_model to indicate "get the list of
@@ -533,7 +535,7 @@ def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
getattr(Meta, 'exclude', None) is None):
warnings.warn("Calling modelform_factory without defining 'fields' or "
"'exclude' explicitly is deprecated",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
# Instatiate type(form) in order to use the same metaclass as form.
return type(form)(class_name, (form,), form_class_attrs)
@@ -825,7 +827,7 @@ def modelformset_factory(model, form=ModelForm, formfield_callback=None,
getattr(meta, 'exclude', exclude) is None):
warnings.warn("Calling modelformset_factory without defining 'fields' or "
"'exclude' explicitly is deprecated",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
form = modelform_factory(model, form=form, fields=fields, exclude=exclude,
formfield_callback=formfield_callback,
View
4 django/forms/util.py
@@ -1,7 +1,9 @@
import warnings
+from django.utils.deprecation import RemovedInDjango19Warning
+
warnings.warn(
"The django.forms.util module has been renamed. "
- "Use django.forms.utils instead.", PendingDeprecationWarning)
+ "Use django.forms.utils instead.", RemovedInDjango19Warning)
from django.forms.utils import * # NOQA
View
5 django/forms/utils.py
@@ -10,8 +10,9 @@
from UserList import UserList
from django.conf import settings
-from django.utils.html import format_html, format_html_join, escape
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text, python_2_unicode_compatible
+from django.utils.html import format_html, format_html_join, escape
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils import six
@@ -40,7 +41,7 @@ def flatatt(attrs):
'action': "be rendered as '%s'" % attr_name if value else "not be rendered",
'bool_value': value,
},
- DeprecationWarning
+ RemovedInDjango18Warning
)
return format_html_join('', ' {0}="{1}"', sorted(attrs.items()))
View
7 django/forms/widgets.py
@@ -11,9 +11,10 @@
from django.conf import settings
from django.forms.utils import flatatt, to_current_timezone
from django.utils.datastructures import MultiValueDict, MergeDict
+from django.utils.deprecation import RemovedInDjango18Warning
+from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import conditional_escape, format_html
from django.utils.translation import ugettext_lazy
-from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.safestring import mark_safe
from django.utils import formats, six
from django.utils.six.moves.urllib.parse import urljoin
@@ -191,7 +192,7 @@ def is_hidden(self, *args):
warnings.warn(
"`is_hidden` property is now read-only (and checks `input_type`). "
"Please update your code.",
- DeprecationWarning, stacklevel=2
+ RemovedInDjango18Warning, stacklevel=2
)
def subwidgets(self, name, value, attrs=None, choices=()):
@@ -636,7 +637,7 @@ def __init__(self, *args, **kwargs):
class RadioInput(RadioChoiceInput):
def __init__(self, *args, **kwargs):
msg = "RadioInput has been deprecated. Use RadioChoiceInput instead."
- warnings.warn(msg, DeprecationWarning, stacklevel=2)
+ warnings.warn(msg, RemovedInDjango18Warning, stacklevel=2)
super(RadioInput, self).__init__(*args, **kwargs)
View
3  django/middleware/cache.py
@@ -48,6 +48,7 @@
from django.conf import settings
from django.core.cache import caches, DEFAULT_CACHE_ALIAS
from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers, get_max_age
+from django.utils.deprecation import RemovedInDjango18Warning
class UpdateCacheMiddleware(object):
@@ -194,6 +195,6 @@ def __init__(self, cache_timeout=None, cache_anonymous_only=None, **kwargs):
if self.cache_anonymous_only:
msg = "CACHE_MIDDLEWARE_ANONYMOUS_ONLY has been deprecated and will be removed in Django 1.8."
- warnings.warn(msg, DeprecationWarning, stacklevel=1)
+ warnings.warn(msg, RemovedInDjango18Warning, stacklevel=1)
self.cache = caches[self.cache_alias]
View
3  django/middleware/common.py
@@ -7,6 +7,7 @@
from django.core.mail import mail_managers
from django.core import urlresolvers
from django import http
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text
from django.utils.http import urlquote
from django.utils import six
@@ -110,7 +111,7 @@ def process_response(self, request, response):
if settings.SEND_BROKEN_LINK_EMAILS:
warnings.warn("SEND_BROKEN_LINK_EMAILS is deprecated. "
"Use BrokenLinkEmailsMiddleware instead.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
BrokenLinkEmailsMiddleware().process_response(request, response)
if settings.USE_ETAGS:
View
5 django/middleware/doc.py
@@ -1,6 +1,9 @@
"""XViewMiddleware has been moved to django.contrib.admindocs.middleware."""
import warnings
-warnings.warn(__doc__, DeprecationWarning, stacklevel=2)
+
+from django.utils.deprecation import RemovedInDjango18Warning
+
+warnings.warn(__doc__, RemovedInDjango18Warning, stacklevel=2)
from django.contrib.admindocs.middleware import XViewMiddleware # NOQA
View
3  django/middleware/transaction.py
@@ -2,6 +2,7 @@
from django.core.exceptions import MiddlewareNotUsed
from django.db import connection, transaction
+from django.utils.deprecation import RemovedInDjango18Warning
class TransactionMiddleware(object):
@@ -15,7 +16,7 @@ class TransactionMiddleware(object):
def __init__(self):
warnings.warn(
"TransactionMiddleware is deprecated in favor of ATOMIC_REQUESTS.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
if connection.settings_dict['ATOMIC_REQUESTS']:
raise MiddlewareNotUsed
View
5 django/template/defaulttags.py
@@ -17,6 +17,7 @@
render_value_in_context)
from django.template.smartif import IfParser, Literal
from django.template.defaultfilters import date
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text, smart_text
from django.utils.safestring import mark_safe
from django.utils.html import format_html
@@ -591,7 +592,7 @@ def cycle(parser, token, escape=False):
"'The `cycle` template tag is changing to escape its arguments; "
"the non-autoescaping version is deprecated. Load it "
"from the `future` tag library to start using the new behavior.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
# Note: This returns the exact same node on each {% cycle name %} call;
# that is, the node object returned from {% cycle a b c as name %} and the
@@ -739,7 +740,7 @@ def firstof(parser, token, escape=False):
"'The `firstof` template tag is changing to escape its arguments; "
"the non-autoescaping version is deprecated. Load it "
"from the `future` tag library to start using the new behavior.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
bits = token.split_contents()[1:]
if len(bits) < 1:
View
5 django/templatetags/future.py
@@ -2,6 +2,7 @@
from django.template import Library
from django.template import defaulttags
+from django.utils.deprecation import RemovedInDjango19Warning
register = Library()
@@ -11,7 +12,7 @@ def ssi(parser, token):
warnings.warn(
"Loading the `ssi` tag from the `future` library is deprecated and "
"will be removed in Django 1.9. Use the default `ssi` tag instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
return defaulttags.ssi(parser, token)
@@ -20,7 +21,7 @@ def url(parser, token):
warnings.warn(
"Loading the `url` tag from the `future` library is deprecated and "
"will be removed in Django 1.9. Use the default `url` tag instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
return defaulttags.url(parser, token)
View
6 django/test/_doctest.py
@@ -51,10 +51,12 @@ def _test():
"""
import warnings
+from django.utils.deprecation import RemovedInDjango18Warning
+
warnings.warn(
"The django.test._doctest module is deprecated; "
"use the doctest module from the Python standard library instead.",
- DeprecationWarning)
+ RemovedInDjango18Warning)
__docformat__ = 'reStructuredText en'
@@ -2085,7 +2087,7 @@ def __init__(self, mod=None, globs=None, verbose=None, optionflags=0):
warnings.warn("class Tester is deprecated; "
"use class doctest.DocTestRunner instead",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
if mod is None and globs is None:
raise TypeError("Tester.__init__: must specify mod or globs")
if mod is not None and not inspect.ismodule(mod):
View
3  django/test/simple.py
@@ -16,6 +16,7 @@
# django.utils.unittest is deprecated, but so is django.test.simple,
# and the latter will be removed before the former.
from django.utils import unittest
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.module_loading import module_has_submodule
__all__ = ('DjangoTestSuiteRunner',)
@@ -23,7 +24,7 @@
warnings.warn(
"The django.test.simple module and DjangoTestSuiteRunner are deprecated; "
"use django.test.runner.DiscoverRunner instead.",
- DeprecationWarning)
+ RemovedInDjango18Warning)
# The module name for tests outside models.py
TEST_MODULE = 'tests'
View
12 django/test/utils.py
@@ -17,8 +17,9 @@
from django.template import Template, loader, TemplateDoesNotExist
from django.template.loaders import cached
from django.test.signals import template_rendered, setting_changed
-from django.utils.encoding import force_str
from django.utils import six
+from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning
+from django.utils.encoding import force_str
from django.utils.translation import deactivate
@@ -457,8 +458,7 @@ def __exit__(self, exc_type, exc_value, traceback):
class IgnoreDeprecationWarningsMixin(object):
-
- warning_classes = [DeprecationWarning]
+ warning_classes = [RemovedInDjango18Warning]
def setUp(self):
super(IgnoreDeprecationWarningsMixin, self).setUp()
@@ -473,13 +473,11 @@ def tearDown(self):
class IgnorePendingDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
-
- warning_classes = [PendingDeprecationWarning]
+ warning_classes = [RemovedInDjango19Warning]
class IgnoreAllDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
-
- warning_classes = [PendingDeprecationWarning, DeprecationWarning]
+ warning_classes = [RemovedInDjango19Warning, RemovedInDjango18Warning]
@contextmanager
View
6 django/utils/datastructures.py
@@ -1,7 +1,9 @@
import copy
import warnings
from collections import OrderedDict
+
from django.utils import six
+from django.utils.deprecation import RemovedInDjango19Warning
class MergeDict(object):
@@ -14,7 +16,7 @@ class MergeDict(object):
"""
def __init__(self, *dicts):
warnings.warn('`MergeDict` is deprecated, use `dict.update()` '
- 'instead.', PendingDeprecationWarning, 2)
+ 'instead.', RemovedInDjango19Warning, 2)
self.dicts = dicts
def __bool__(self):
@@ -131,7 +133,7 @@ def __new__(cls, *args, **kwargs):
def __init__(self, data=None):
warnings.warn(
"SortedDict is deprecated and will be removed in Django 1.9.",
- PendingDeprecationWarning, stacklevel=2
+ RemovedInDjango19Warning, stacklevel=2
)
if data is None or isinstance(data, dict):
data = data or []
View
8 django/utils/deprecation.py
@@ -2,6 +2,14 @@
import warnings
+class RemovedInDjango19Warning(PendingDeprecationWarning):
+ pass
+
+
+class RemovedInDjango18Warning(DeprecationWarning):
+ pass
+
+
class warn_about_renamed_method(object):
def __init__(self, class_name, old_method_name, new_method_name, deprecation_warning):
self.class_name = class_name
View
4 django/utils/dictconfig.py
@@ -1,7 +1,9 @@
import warnings
+from django.utils.deprecation import RemovedInDjango19Warning
+
warnings.warn("django.utils.dictconfig will be removed in Django 1.9.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
# This is a copy of the Python logging.config.dictconfig module,
# reproduced with permission. It is provided here for backwards
View
3  django/utils/functional.py
@@ -5,6 +5,7 @@
import warnings
from django.utils import six
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.six.moves import copyreg
@@ -27,7 +28,7 @@ def memoize(func, cache, num_args):
"""
warnings.warn("memoize wrapper is deprecated and will be removed in "
"Django 1.9. Use django.utils.lru_cache instead.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
@wraps(func)
def wrapper(*args):
View
7 django/utils/html.py
@@ -5,9 +5,10 @@
import re
import warnings
-from django.utils.safestring import SafeData, mark_safe
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text, force_str
from django.utils.functional import allow_lazy
+from django.utils.safestring import SafeData, mark_safe
from django.utils import six
from django.utils.six.moves.urllib.parse import quote, unquote, urlsplit, urlunsplit
from django.utils.text import normalize_newlines
@@ -177,7 +178,7 @@ def fix_ampersands(value):
"""Returns the given HTML with all unencoded ampersands encoded correctly."""
# As fix_ampersands is wrapped in allow_lazy, stacklevel 3 is more useful than 2.
warnings.warn("The fix_ampersands function is deprecated and will be removed in Django 1.8.",
- DeprecationWarning, stacklevel=3)
+ RemovedInDjango18Warning, stacklevel=3)
return unencoded_ampersands_re.sub('&amp;', force_text(value))
fix_ampersands = allow_lazy(fix_ampersands, six.text_type)
@@ -296,7 +297,7 @@ def clean_html(text):
"""
# As clean_html is wrapped in allow_lazy, stacklevel 3 is more useful than 2.
warnings.warn("The clean_html function is deprecated and will be removed in Django 1.8.",
- DeprecationWarning, stacklevel=3)
+ RemovedInDjango18Warning, stacklevel=3)
text = normalize_newlines(text)
text = re.sub(r'<(/?)\s*b\s*>', '<\\1strong>', text)
text = re.sub(r'<(/?)\s*i\s*>', '<\\1em>', text)
View
3  django/utils/image.py
@@ -75,6 +75,7 @@
import warnings
from django.core.exceptions import ImproperlyConfigured
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.translation import ugettext_lazy as _
@@ -147,7 +148,7 @@ def _detect_image_library():
warnings.warn(
"Support for the PIL will be removed in Django 1.8. Please " +
"uninstall it & install Pillow instead.",
- DeprecationWarning
+ RemovedInDjango18Warning
)
return PILImage, PIL_imaging, PILImageFile
View
4 django/utils/importlib.py
@@ -3,9 +3,11 @@
import sys
from django.utils import six
+from django.utils.deprecation import RemovedInDjango19Warning
+
warnings.warn("django.utils.importlib will be removed in Django 1.9.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
def _resolve_name(name, package, level):
View
3  django/utils/module_loading.py
@@ -9,6 +9,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.utils import six
+from django.utils.deprecation import RemovedInDjango19Warning
def import_string(dotted_path):
@@ -39,7 +40,7 @@ def import_by_path(dotted_path, error_prefix=''):
"""
warnings.warn(
'import_by_path() has been deprecated. Use import_string() instead.',
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
try:
attr = import_string(dotted_path)
except ImportError as e:
View
3  django/utils/text.py
@@ -6,6 +6,7 @@
from io import BytesIO
import warnings
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_text
from django.utils.functional import allow_lazy, SimpleLazyObject
from django.utils import six
@@ -332,7 +333,7 @@ def javascript_quote(s, quote_double_quotes=False):
"django.utils.text.javascript_quote() is deprecated. "
"Use django.utils.html.escapejs() instead."
)
- warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
+ warnings.warn(msg, RemovedInDjango19Warning, stacklevel=2)
def fix(match):
return "\\u%04x" % ord(match.group(1))
View
3  django/utils/translation/trans_real.py
@@ -12,6 +12,7 @@
from django.apps import apps
from django.dispatch import receiver
from django.test.signals import setting_changed
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_str, force_text
from django.utils._os import upath
from django.utils.safestring import mark_safe, SafeData
@@ -213,7 +214,7 @@ def activate(language):
msg = ("The use of the language code '%s' is deprecated. "
"Please use the '%s' translation instead.")
warnings.warn(msg % (language, _DJANGO_DEPRECATED_LOCALES[language]),
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
_active.value = translation(language)
View
7 django/utils/tzinfo.py
@@ -6,12 +6,13 @@
import time
import warnings
+from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_str, force_text, DEFAULT_LOCALE_ENCODING
warnings.warn(
"django.utils.tzinfo will be removed in Django 1.9. "
"Use django.utils.timezone instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
# Python's doc say: "A tzinfo subclass must have an __init__() method that can
@@ -25,7 +26,7 @@ def __init__(self, offset):
warnings.warn(
"django.utils.tzinfo.FixedOffset will be removed in Django 1.9. "
"Use django.utils.timezone.get_fixed_timezone instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
if isinstance(offset, timedelta):
self.__offset = offset
offset = self.__offset.seconds // 60
@@ -63,7 +64,7 @@ def __init__(self, dt):
warnings.warn(
"django.utils.tzinfo.LocalTimezone will be removed in Django 1.9. "
"Use django.utils.timezone.get_default_timezone instead.",
- PendingDeprecationWarning)
+ RemovedInDjango19Warning)
tzinfo.__init__(self)
self.__dt = dt
self._tzname = self.tzname(dt)
View
4 django/utils/unittest.py
@@ -2,8 +2,10 @@
import warnings
+from django.utils.deprecation import RemovedInDjango19Warning
+
warnings.warn("django.utils.unittest will be removed in Django 1.9.",
- PendingDeprecationWarning, stacklevel=2)
+ RemovedInDjango19Warning, stacklevel=2)
try:
from unittest2 import *
View
3  django/views/defaults.py
@@ -3,6 +3,7 @@
from django import http
from django.template import (Context, RequestContext,
loader, Template, TemplateDoesNotExist)
+from django.utils.deprecation import RemovedInDjango18Warning
from django.views.decorators.csrf import requires_csrf_token
@@ -86,6 +87,6 @@ def shortcut(request, content_type_id, object_id):
warnings.warn(
"django.views.defaults.shortcut will be removed in Django 1.8. "
"Import it from django.contrib.contenttypes.views instead.",
- DeprecationWarning, stacklevel=2)
+ RemovedInDjango18Warning, stacklevel=2)
from django.contrib.contenttypes.views import shortcut as real_shortcut
return real_shortcut(request, content_type_id, object_id)
View
5 django/views/generic/edit.py
@@ -1,8 +1,9 @@
import warnings
-from django.forms import models as model_forms
from django.core.exceptions import ImproperlyConfigured
+from django.forms import models as model_forms
from django.http import HttpResponseRedirect
+from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text
from django.views.generic.base import TemplateResponseMixin, ContextMixin, View
from django.views.generic.detail import (SingleObjectMixin,
@@ -113,7 +114,7 @@ def get_form_class(self):
if self.fields is None:
warnings.warn("Using ModelFormMixin (base class of %s) without "
"the 'fields' attribute is deprecated." % self.__class__.__name__,
- DeprecationWarning)
+ RemovedInDjango18Warning)
return model_forms.modelform_factory(model, fields=self.fields)
View
10 docs/internals/contributing/writing-code/submitting-patches.txt
@@ -173,11 +173,12 @@ There are a couple reasons that code in Django might be deprecated:
As the :ref:`deprecation policy<internal-release-deprecation-policy>` describes,
the first release of Django that deprecates a feature (``A.B``) should raise a
-``PendingDeprecationWarning`` when the deprecated feature is invoked. Assuming
+``RemovedInDjangoXXWarning`` (where XX is the Django version where the feature
+will be removed) when the deprecated feature is invoked. Assuming
we have a good test coverage, these warnings will be shown by the test suite
when :ref:`running it <running-unit-tests>` with warnings enabled:
``python -Wall runtests.py``. This is annoying and the output of the test suite
-should remain clean. Thus, when adding a ``PendingDeprecationWarning`` you need
+should remain clean. Thus, when adding a ``RemovedInDjangoXXWarning`` you need
to eliminate or silence any warnings generated when running the tests.
The first step is to remove any use of the deprecated behavior by Django itself.
@@ -218,9 +219,8 @@ Finally, there are a couple of updates to Django's documentation to make:
under the ``A.B+2`` version describing what code will be removed.
Once you have completed these steps, you are finished with the deprecation.
-In each minor release, all ``PendingDeprecationWarning``\s are promoted to
-``DeprecationWarning``\s and any features marked with ``DeprecationWarning``
-are removed.
+In each minor release, all ``RemovedInDjangoXXWarning``\s matching the new
+version are removed.
Javascript patches
------------------