[4.0.x] Fixed #33234 -- Fixed autodetector crash for proxy models inheriting from non-model class.
Regression inaa4acc164d
. Thanks Kevin Marsh for the report. Backport ofdab48b7482
from main
This commit is contained in:
parent
b4ad6e32ca
commit
e2fe0429ab
|
@ -476,6 +476,8 @@ class ProjectState:
|
|||
|
||||
def _find_concrete_model_from_proxy(self, proxy_models, model_state):
|
||||
for base in model_state.bases:
|
||||
if not (isinstance(base, str) or issubclass(base, models.Model)):
|
||||
continue
|
||||
base_key = make_model_tuple(base)
|
||||
base_state = proxy_models.get(base_key)
|
||||
if not base_state:
|
||||
|
|
|
@ -1779,6 +1779,29 @@ class AutodetectorTests(TestCase):
|
|||
self.assertOperationAttributes(changes, "testapp", 0, 0, name="AuthorProxy")
|
||||
self.assertOperationAttributes(changes, "testapp", 0, 1, name="AuthorProxy", options={})
|
||||
|
||||
def test_proxy_non_model_parent(self):
|
||||
class Mixin:
|
||||
pass
|
||||
|
||||
author_proxy_non_model_parent = ModelState(
|
||||
'testapp',
|
||||
'AuthorProxy',
|
||||
[],
|
||||
{'proxy': True},
|
||||
(Mixin, 'testapp.author'),
|
||||
)
|
||||
changes = self.get_changes(
|
||||
[self.author_empty],
|
||||
[self.author_empty, author_proxy_non_model_parent],
|
||||
)
|
||||
self.assertNumberMigrations(changes, 'testapp', 1)
|
||||
self.assertOperationTypes(changes, 'testapp', 0, ['CreateModel'])
|
||||
self.assertOperationAttributes(
|
||||
changes, 'testapp', 0, 0, name='AuthorProxy',
|
||||
options={'proxy': True, 'indexes': [], 'constraints': []},
|
||||
bases=(Mixin, 'testapp.author'),
|
||||
)
|
||||
|
||||
def test_proxy_custom_pk(self):
|
||||
"""
|
||||
#23415 - The autodetector must correctly deal with custom FK on proxy
|
||||
|
|
Loading…
Reference in New Issue