diff --git a/scipost_django/journals/models/publication.py b/scipost_django/journals/models/publication.py index 79ea588fb3d198b9c028f3295fa506490e42267d..478577f960887da700d9919a7bd31bd2ba1f37de 100644 --- a/scipost_django/journals/models/publication.py +++ b/scipost_django/journals/models/publication.py @@ -297,6 +297,10 @@ class Publication(models.Model): for idx, aff in enumerate(self.get_all_affiliations()): if aff in author.affiliations.all(): affnrs.append(idx + 1) + # If no affiliation is found, add a None to the list + # Prevents crashes since Django v4 + if len(affnrs) == 0: + affnrs = [None] indexed_author_list.append(affnrs) # Since nested ArrayFields must have the same dimension, # we pad the "empty" entries with Null: