diff --git a/wcivf/apps/people/management/commands/import_people.py b/wcivf/apps/people/management/commands/import_people.py index 8b3481c25..fd8bc360c 100644 --- a/wcivf/apps/people/management/commands/import_people.py +++ b/wcivf/apps/people/management/commands/import_people.py @@ -253,8 +253,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()