From f82161d648cb06f57cabc57f45f13ac99f4f43fd Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 19 Jun 2021 08:37:53 -0700 Subject: [PATCH] Fixes migration query --- ...hysical_format_edition_physical_format_detail.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bookwyrm/migrations/0077_rename_physical_format_edition_physical_format_detail.py b/bookwyrm/migrations/0077_rename_physical_format_edition_physical_format_detail.py index eec94d626..020cc49ab 100644 --- a/bookwyrm/migrations/0077_rename_physical_format_edition_physical_format_detail.py +++ b/bookwyrm/migrations/0077_rename_physical_format_edition_physical_format_detail.py @@ -11,7 +11,7 @@ def infer_format(app_registry, schema_editor): editions = ( app_registry.get_model("bookwyrm", "Edition") .objects.using(db_alias) - .filter(physical_format__isnull=False) + .filter(physical_format_detail__isnull=False) ) mappings = { "paperback": "Paperback", @@ -56,19 +56,16 @@ def infer_format(app_registry, schema_editor): "graphic": "GraphicNovel", } for edition in editions: - free_format = editions.physical_format_detail.lower() - print(free_format) + free_format = edition.physical_format_detail.lower() if free_format in mappings: - print("hi") edition.physical_format = mappings[free_format] - edition.save(broadcast=False) + edition.save() else: - matches = [v for k, v in mappings if k in free_format] - print(matches) + matches = [v for k, v in mappings.items() if k in free_format] if not matches: continue edition.physical_format = matches[0] - edition.save(broadcast=False) + edition.save() def reverse(app_registry, schema_editor): """doesn't need to do anything"""