diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1281b8fa9f2b612ca1fcd501055ceb595488a156..54bde9373660c7685c531148cb3d6f540da38f27 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,6 +9,12 @@ and this project adheres to `Semantic Versioning`_. Unreleased ---------- +Fixed +~~~~~ + +* Guessing school ID could fail in `aleksis-admin migrate` under some + version conditions + `2.3.1`_ - 2022-08-13 --------------------- diff --git a/aleksis/apps/untis/migrations/0003_guess_school_id.py b/aleksis/apps/untis/migrations/0003_guess_school_id.py index 79a2d2743d4e0dbfd6c1e496bf10ec72fa6284c3..090fd6d96071dbbd5170bf0ac757040be1048f01 100644 --- a/aleksis/apps/untis/migrations/0003_guess_school_id.py +++ b/aleksis/apps/untis/migrations/0003_guess_school_id.py @@ -13,9 +13,10 @@ def guess_school_id(apps, schema_editor): except ValidityRange.DoesNotExist: return - school_id = vr.school_id_untis - if school_id: - get_site_preferences()["untis_mysql__school_id"] = school_id + if not vr or not vr.school_id_untis: + return + + get_site_preferences()["untis_mysql__school_id"] = school_id class Migration(migrations.Migration):