Loading django/db/models/options.py +5 −0 Original line number Diff line number Diff line Loading @@ -255,6 +255,11 @@ class Options(object): field = already_created[0] field.primary_key = True self.setup_pk(field) if not field.remote_field.parent_link: warnings.warn( 'Add parent_link=True to %s as an implicit link is ' 'deprecated.' % field, RemovedInDjango20Warning ) else: auto = AutoField(verbose_name='ID', primary_key=True, auto_created=True) model.add_to_class('id', auto) Loading docs/internals/deprecation.txt +3 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,9 @@ details on these changes. * The ``django.contrib.gis.utils.precision_wkt()`` function will be removed. * In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a ``parent_link`` will be removed. .. _deprecation-removed-in-1.10: 1.10 Loading docs/releases/1.10.txt +3 −0 Original line number Diff line number Diff line Loading @@ -980,6 +980,9 @@ Miscellaneous favor of class-based views :class:`~django.views.i18n.JavaScriptCatalog` and :class:`~django.views.i18n.JSONCatalog`. * In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a ``parent_link`` is deprecated. Add ``parent_link=True`` to such fields. .. _removed-features-1.10: Features removed in 1.10 Loading tests/invalid_models_tests/test_models.py +22 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ from __future__ import unicode_literals import unittest import warnings from django.conf import settings from django.core.checks import Error Loading Loading @@ -739,3 +740,24 @@ class OtherModelTests(SimpleTestCase): ) ] self.assertEqual(errors, expected) def test_missing_parent_link(self): with warnings.catch_warnings(record=True) as warns: warnings.simplefilter('always') class Place(models.Model): pass class ParkingLot(Place): # In lieu of any other connector, an existing OneToOneField will be # promoted to the primary key. parent = models.OneToOneField(Place, models.CASCADE) self.assertEqual(len(warns), 1) msg = str(warns[0].message) self.assertEqual( msg, 'Add parent_link=True to invalid_models_tests.ParkingLot.parent ' 'as an implicit link is deprecated.' ) self.assertEqual(ParkingLot._meta.pk.name, 'parent') tests/migrations/test_operations.py +1 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ class OperationTestBase(MigrationTestBase): 'Pony', models.CASCADE, auto_created=True, parent_link=True, primary_key=True, to_field='id', serialize=False, Loading Loading
django/db/models/options.py +5 −0 Original line number Diff line number Diff line Loading @@ -255,6 +255,11 @@ class Options(object): field = already_created[0] field.primary_key = True self.setup_pk(field) if not field.remote_field.parent_link: warnings.warn( 'Add parent_link=True to %s as an implicit link is ' 'deprecated.' % field, RemovedInDjango20Warning ) else: auto = AutoField(verbose_name='ID', primary_key=True, auto_created=True) model.add_to_class('id', auto) Loading
docs/internals/deprecation.txt +3 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,9 @@ details on these changes. * The ``django.contrib.gis.utils.precision_wkt()`` function will be removed. * In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a ``parent_link`` will be removed. .. _deprecation-removed-in-1.10: 1.10 Loading
docs/releases/1.10.txt +3 −0 Original line number Diff line number Diff line Loading @@ -980,6 +980,9 @@ Miscellaneous favor of class-based views :class:`~django.views.i18n.JavaScriptCatalog` and :class:`~django.views.i18n.JSONCatalog`. * In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a ``parent_link`` is deprecated. Add ``parent_link=True`` to such fields. .. _removed-features-1.10: Features removed in 1.10 Loading
tests/invalid_models_tests/test_models.py +22 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ from __future__ import unicode_literals import unittest import warnings from django.conf import settings from django.core.checks import Error Loading Loading @@ -739,3 +740,24 @@ class OtherModelTests(SimpleTestCase): ) ] self.assertEqual(errors, expected) def test_missing_parent_link(self): with warnings.catch_warnings(record=True) as warns: warnings.simplefilter('always') class Place(models.Model): pass class ParkingLot(Place): # In lieu of any other connector, an existing OneToOneField will be # promoted to the primary key. parent = models.OneToOneField(Place, models.CASCADE) self.assertEqual(len(warns), 1) msg = str(warns[0].message) self.assertEqual( msg, 'Add parent_link=True to invalid_models_tests.ParkingLot.parent ' 'as an implicit link is deprecated.' ) self.assertEqual(ParkingLot._meta.pk.name, 'parent')
tests/migrations/test_operations.py +1 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ class OperationTestBase(MigrationTestBase): 'Pony', models.CASCADE, auto_created=True, parent_link=True, primary_key=True, to_field='id', serialize=False, Loading