diff options
| author | Daniel Patrick <github@danielpatrick.dev> | 2024-07-03 19:23:59 +0100 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-07-10 08:40:50 +0200 |
| commit | d12184fedcd586e2c399ea40abe4bf865ebc87a6 (patch) | |
| tree | f25d6b9adea7ccbe7f443a3d2a4383319bf14bc5 /django | |
| parent | e095c7612d49dbe371e9c7edd76ba99b6bc4f9f6 (diff) | |
Fixed #35424 -- Checked order_with_respect_to is available when migrating _order fields.
Migrations would crash following the removal of an order_with_respect_to
field from a model and the addition of an _order field.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/migrations/state.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py index 42a2c80a5e..e13de5ba6f 100644 --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -761,8 +761,11 @@ class ModelState: return self.name.lower() def get_field(self, field_name): - if field_name == "_order": - field_name = self.options.get("order_with_respect_to", field_name) + if ( + field_name == "_order" + and self.options.get("order_with_respect_to") is not None + ): + field_name = self.options["order_with_respect_to"] return self.fields[field_name] @classmethod |
