How to add things to the `created_resources` list of a task

When uploading a package using the repository parameter using:

${HTTP_CMD} --form post ${PULP_URL}/pulp/api/v3/content/deb/packages/ file@../frigg_1.0_ppc64.deb repository=${REPOSITORY_HREF}

We get the following Task:

  "pulp_href": "/pulp/api/v3/tasks/cc564084-002e-4468-885c-31c2739a959e/",
  "pulp_created": "2023-04-20T09:44:31.806989Z",
  "state": "completed",
  "name": "",
  "logging_cid": "efd74e434bda4dd48a1629dade0f24fd",
  "started_at": "2023-04-20T09:44:31.958019Z",
  "finished_at": "2023-04-20T09:44:33.697890Z",
  "error": null,
  "worker": "/pulp/api/v3/workers/46a9999d-ea88-4ecc-80c4-49662e7ba352/",
  "parent_task": null,
  "child_tasks": [],
  "task_group": null,
  "progress_reports": [],
  "created_resources": [
  "reserved_resources_record": [

With this PR we have modified the behaviour of our serializer to additionally also create a ReleaseComponent and PackageReleaseComponent. However, these do not appear in the list of created_resources, since the Task does not know about them.

My question is: Is there a way of creating additional entities in a serializer, that will make those entities appear in the created_resources list?

It all boils down to creating a db record for it:

resource = CreatedResource(content_object=instance)