Skip to content

Commit ff7ea9a

Browse files
askoretskiyPhotonios
authored andcommitted
Add compatibility with Django 3.1
1 parent 6bece6e commit ff7ea9a

File tree

1 file changed

+10
-1
lines changed
  • psqlextra/backend/migrations/state

1 file changed

+10
-1
lines changed

psqlextra/backend/migrations/state/model.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Mapping
12
from typing import Type
23

34
from django.db.migrations.state import ModelState
@@ -68,7 +69,15 @@ def render(self, apps):
6869
"Cannot resolve one or more bases from %r" % (self.bases,)
6970
)
7071

71-
fields = {name: field.clone() for name, field in self.fields}
72+
if isinstance(self.fields, Mapping):
73+
# In Django 3.1 `self.fields` became a `dict`
74+
fields = {
75+
name: field.clone() for name, field in self.fields.items()
76+
}
77+
else:
78+
# In Django < 3.1 `self.fields` is a list of (name, field) tuples
79+
fields = {name: field.clone() for name, field in self.fields}
80+
7281
meta = type(
7382
"Meta",
7483
(),

0 commit comments

Comments
 (0)