You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 a HalListSerializer
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.
The text was updated successfully, but these errors were encountered:
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 adict
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 alist
ofdict
. Obviously, alist
cannot have a_links
key so the PR at Antory\drf-hal-json#20:ListSerializer
with aHalListSerializer
-list
of the resourceAny 3rd party formatter that is incompatible with a top-level
ListSerializer
would require a similar change. Unfortunately. the defaultListSerializer
is hard coded inmany_init
. To (1) continue to support a user-definedMeta
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 theHalModelSerializer
.The infrastructure for constructing
-detail
URLs is also spread across several files. This plugin needed the same for-list
. Because there's no call supportingview_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 aview_name
in other cases.The text was updated successfully, but these errors were encountered: