We noticed that the URL field was no longer being included in the responses from our endpoints, and I tracked it down to this diff:
\nhttps://github.com/django-json-api/django-rest-framework-json-api/pull/1221/files#diff-52135bfc77d9d40d99d5451d1c64e64d75f0ae5bd338162064891dfcfc27b3b0R78
I'm just hoping to get more information on what the intent behind that change was, and what a suitable workaround would be for us. Didn't want to file a bug since it seems like an intentional change.
","upvoteCount":3,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Thanks for bringing this up. The URL field is tricky. It is actually a reserved field used by HyperlinkedModelSerializer to define the identity location. The name can actually be configured with URL_FIELD_NAME which is per default url. This URL field is used in JSON:API as a self-link. That it is why the URL is excluded in attributes.
However it should actually only be excluded if it is a URL field name and of type HyperlinkedIdentityField. So this is a regression.
\nI will have a look and see how easy it is to fix also considering that sparse fields should handle URL as a field if it is overwritten as you do it (that was the initial change, which caused this regression).
\nWhat you can do as a simple workaround is setting URL_FIELD_NAME to a different name than url e.g. self or similar and the URL should appear again in attributes.
url field is no longer present in serializers using the rest_framework_json_api.JSONRenderer
#1233
-
|
Up until release 7.0.0 in our project we were specifying We noticed that the URL field was no longer being included in the responses from our endpoints, and I tracked it down to this diff: I'm just hoping to get more information on what the intent behind that change was, and what a suitable workaround would be for us. Didn't want to file a bug since it seems like an intentional change. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for bringing this up. The URL field is tricky. It is actually a reserved field used by HyperlinkedModelSerializer to define the identity location. The name can actually be configured with However it should actually only be excluded if it is a URL field name and of type HyperlinkedIdentityField. So this is a regression. I will have a look and see how easy it is to fix also considering that sparse fields should handle URL as a field if it is overwritten as you do it (that was the initial change, which caused this regression). What you can do as a simple workaround is setting URL_FIELD_NAME to a different name than |
Beta Was this translation helpful? Give feedback.
Thanks for bringing this up. The URL field is tricky. It is actually a reserved field used by HyperlinkedModelSerializer to define the identity location. The name can actually be configured with
URL_FIELD_NAMEwhich is per defaulturl. This URL field is used in JSON:API as a self-link. That it is why the URL is excluded in attributes.However it should actually only be excluded if it is a URL field name and of type HyperlinkedIdentityField. So this is a regression.
I will have a look and see how easy it is to fix also considering that sparse fields should handle URL as a field if it is overwritten as you do it (that was the initial change, which caused this regression).
What you can do as…