浏览代码

Fixed #28750 -- Allowed models to define Meta.manager_inheritance_from_future for backwards compatibility.

Refs 631f4ab06112aca5bd6a57b81159048f936050bf.
Charlie Denton 7 年之前
父节点
当前提交
cbe334918a
共有 2 个文件被更改,包括 17 次插入0 次删除
  1. 2 0
      django/db/models/options.py
  2. 15 0
      tests/model_meta/test_manager_inheritance_from_future.py

+ 2 - 0
django/db/models/options.py

@@ -33,6 +33,8 @@ DEFAULT_NAMES = (
     'select_on_save', 'default_related_name', 'required_db_features',
     'required_db_vendor', 'base_manager_name', 'default_manager_name',
     'indexes',
+    # For backwards compatibility with Django 1.11. RemovedInDjango30Warning
+    'manager_inheritance_from_future',
 )
 
 

+ 15 - 0
tests/model_meta/test_manager_inheritance_from_future.py

@@ -0,0 +1,15 @@
+from django.db import models
+from django.test import SimpleTestCase
+from django.test.utils import isolate_apps
+
+
+@isolate_apps('model_meta')
+class TestManagerInheritanceFromFuture(SimpleTestCase):
+    def test_defined(self):
+        """
+        Meta.manager_inheritance_from_future can be defined for backwards
+        compatibility with Django 1.11.
+        """
+        class FuturisticModel(models.Model):
+            class Meta:
+                manager_inheritance_from_future = True  # No error raised.