code: def sync_deleted_attachments(self, api_post):
          existing_IDs = set(Post.objects.filter(site_id=self.site_id,
                                                 post_type="attachment",
                                                 parent__icontains='"ID":{}'.format(api_post["ID"]))
                                         .values_list("wp_id", flat=True))
          if existing_IDs:
              api_IDs = set()
              path = "sites/{}/posts/".format(self.site_id)
              params = {
                  "type": "attachment",
                  "parent_id": api_post["ID"],
                  "fields": "ID",
                  "number": 100
              }
              page = 1
              response = self.get(path, params)
              if not response.ok:
                  logger.warning("Response NOT OK! status_code=%s\n%s", response.status_code, response.text)
              while response.ok and response.text and page < 10:
                  api_json = response.json()
                  api_attachments = api_json.get("posts", [])
                  api_IDs |= set(a["ID"] for a in api_attachments)
                  page += 1
                  next_page_handle = api_json.get("meta", {}).get("next_page")
                  if next_page_handle:
                      params["page_handle"] = next_page_handle
                  else:
                      break
                  response = self.get(path, params)
                  if not response.ok:
                      logger.warning("Response NOT OK! status_code=%s\n%s", response.status_code, response.text)
                      return
              to_remove = existing_IDs - api_IDs
              if to_remove:
                  Post.objects.filter(site_id=self.site_id,
                                      post_type="attachment",
                                      parent__icontains='"ID":{}'.format(api_post["ID"]),
                                      wp_id__in=list(to_remove)).delete()