Kaydet (Commit) 5bcca2a0 authored tarafından Tim Graham's avatar Tim Graham

Refs #27532 -- Removed Model._meta.has_auto_field per deprecation timeline.

üst 48d57788
import copy
import inspect
import warnings
from bisect import bisect
from collections import OrderedDict, defaultdict
......@@ -13,7 +12,6 @@ from django.db.models.fields import AutoField
from django.db.models.fields.proxy import OrderWrt
from django.db.models.query_utils import PathInfo
from django.utils.datastructures import ImmutableList, OrderedSet
from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.functional import cached_property
from django.utils.text import camel_case_to_spaces, format_lazy
from django.utils.translation import override
......@@ -818,19 +816,6 @@ class Options:
self._get_fields_cache[cache_key] = fields
return fields
@property
def has_auto_field(self):
warnings.warn(
'Model._meta.has_auto_field is deprecated in favor of checking if '
'Model._meta.auto_field is not None.',
RemovedInDjango21Warning, stacklevel=2
)
return self.auto_field is not None
@has_auto_field.setter
def has_auto_field(self, value):
pass
@cached_property
def _property_names(self):
"""Return a set of the names of the properties defined on the model."""
......
......@@ -254,3 +254,5 @@ how to remove usage of these features.
* The ``USE_ETAGS`` setting is removed. ``CommonMiddleware`` and
``django.utils.cache.patch_response_headers()`` no longer set ETags.
* The ``Model._meta.has_auto_field`` attribute is removed.
import warnings
from django.test import SimpleTestCase
from .models import Person
class HasAutoFieldTests(SimpleTestCase):
def test_get_warns(self):
with warnings.catch_warnings(record=True) as warns:
warnings.simplefilter('always')
Person._meta.has_auto_field
self.assertEqual(len(warns), 1)
self.assertEqual(
str(warns[0].message),
'Model._meta.has_auto_field is deprecated in favor of checking if '
'Model._meta.auto_field is not None.',
)
def test_set_does_nothing(self):
Person._meta.has_auto_field = True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment