Description
drf-hal-json
(linked to the active fork) is a 3rd party library that formats responses in compliance with the HAL spec. The HAL spec requires that all resources (including -list
) be rendered as a dict
with a link to its own URL (in _links.self.href
).
The default behavior of DRF for an unpaged -list
resource is to render it as a list
of dict
. Obviously, a list
cannot have a _links
key so the PR at Antory\drf-hal-json#20:
- replaces the default
ListSerializer
with aHalListSerializer
- constructs a link for the
-list
of the resource
Any 3rd party formatter that is incompatible with a top-level ListSerializer
would require a similar change. Unfortunately. the default ListSerializer
is hard coded in many_init
. To (1) continue to support a user-defined Meta
value, (2) change the default, and (3) avoid duplicating core code, the PR conditionally injects the new default into Meta. It would be simpler/cleaner if the default was configurable on the class and could be overridden by the HalModelSerializer
.
The infrastructure for constructing -detail
URLs is also spread across several files. This plugin needed the same for -list
. Because there's no call supporting view_name
, the PR adds a meta option to override the default. I'm not sure if the same setting would be any help in the core, but wanted to at least draw attention to it as it might eliminate the need for a view_name
in other cases.