From 75374d3797c2cd2423982a870bb0bc74821e951f Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 3 Sep 2015 14:57:57 -0400 Subject: [PATCH] Refs #24099 -- Removed compatibility shim for ContentType.name field. --- django/contrib/contenttypes/models.py | 11 ----------- docs/ref/contrib/contenttypes.txt | 5 ----- tests/contenttypes_tests/test_models.py | 21 --------------------- 3 files changed, 37 deletions(-) diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py index 27a5388a702..a0c9fb0903a 100644 --- a/django/contrib/contenttypes/models.py +++ b/django/contrib/contenttypes/models.py @@ -1,11 +1,8 @@ from __future__ import unicode_literals -import warnings - from django.apps import apps from django.db import models from django.db.utils import IntegrityError, OperationalError, ProgrammingError -from django.utils.deprecation import RemovedInDjango110Warning from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ @@ -36,14 +33,6 @@ class ContentTypeManager(models.Manager): key = (opts.app_label, opts.model_name) return self.__class__._cache[self.db][key] - def create(self, **kwargs): - if 'name' in kwargs: - del kwargs['name'] - warnings.warn( - "ContentType.name field doesn't exist any longer. Please remove it from your code.", - RemovedInDjango110Warning, stacklevel=2) - return super(ContentTypeManager, self).create(**kwargs) - def get_for_model(self, model, for_concrete_model=True): """ Returns the ContentType object for a given model, creating the diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt index d3050398119..243a96aa550 100644 --- a/docs/ref/contrib/contenttypes.txt +++ b/docs/ref/contrib/contenttypes.txt @@ -82,11 +82,6 @@ The ``ContentType`` model :attr:`verbose_name ` attribute of the model. -.. versionchanged:: 1.8 - - Before Django 1.8, the ``name`` property was a real field on the - ``ContentType`` model. - Let's look at an example to see how this works. If you already have the :mod:`~django.contrib.contenttypes` application installed, and then add :mod:`the sites application ` to your diff --git a/tests/contenttypes_tests/test_models.py b/tests/contenttypes_tests/test_models.py index eb436b6a64a..37e0b930486 100644 --- a/tests/contenttypes_tests/test_models.py +++ b/tests/contenttypes_tests/test_models.py @@ -1,7 +1,5 @@ from __future__ import unicode_literals -import warnings - from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.views import shortcut from django.contrib.sites.shortcuts import get_current_site @@ -247,25 +245,6 @@ class ContentTypesTests(TestCase): ct_fetched = ContentType.objects.get_for_id(ct.pk) self.assertIsNone(ct_fetched.model_class()) - def test_name_deprecation(self): - """ - ContentType.name has been removed. Test that a warning is emitted when - creating a ContentType with a `name`, but the creation should not fail. - """ - with warnings.catch_warnings(record=True) as warns: - warnings.simplefilter('always') - ContentType.objects.create( - name='Name', - app_label='contenttypes', - model='OldModel', - ) - self.assertEqual(len(warns), 1) - self.assertEqual( - str(warns[0].message), - "ContentType.name field doesn't exist any longer. Please remove it from your code." - ) - self.assertTrue(ContentType.objects.filter(model='OldModel').exists()) - @mock.patch('django.contrib.contenttypes.models.ContentTypeManager.get_or_create') @mock.patch('django.contrib.contenttypes.models.ContentTypeManager.get') def test_message_if_get_for_model_fails(self, mocked_get, mocked_get_or_create):