diff --git a/wcivf/apps/people/management/commands/import_people.py b/wcivf/apps/people/management/commands/import_people.py index e0362e6d8..f7ff21905 100644 --- a/wcivf/apps/people/management/commands/import_people.py +++ b/wcivf/apps/people/management/commands/import_people.py @@ -250,8 +250,14 @@ def delete_merged_people(self): while url: req = requests.get(url) page = req.json() - for result in page["results"]: - merged_ids.append(result["old_person_id"]) + try: + for result in page["results"]: + merged_ids.append(result["old_person_id"]) + except KeyError as e: + if "Request was throttled" not in page.get("detail", ""): + self.stdout.write(f"Error: {e}") + else: + raise e url = page.get("next") Person.objects.filter(ynr_id__in=merged_ids).delete()