-
Notifications
You must be signed in to change notification settings - Fork 301
Dynamic object-dependent metadata #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Good question, I'm likely going to need this feature myself next week. Currently the So there is |
Actually, IMO, Using the serializer's fields in meta makes sense as the behavior of getting instance related data is what the serializer itself is made for... A usage I have myself is a custom I don't think it should be too hard to write an |
What about adding meta to object list endpoints? The pull request handles detail requests with get_root_meta but not lists. |
@riklaunim they were supposed to work the same. Looks like this test needs to be duplicated and modified to fetch a list instead of a single post so we can test that case. https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/example/tests/integration/test_meta.py#L10 |
I've added the test for list view. Also the most handy metadata for typical list/get/create/update frontend apps is under OPTIONS request in DRF - like options for choices fields or max lengths, is required etc. That meta can be fetched in code http://www.django-rest-framework.org/api-guide/metadata/#creating-schema-endpoints :
But it expects to be called in a view not in the serializer. So either second request (OPTIONS) is required or some way to add the most interesting part of that metadata to default metadata of normal requests. |
It would be useful to be able to specify that a field or fields on a serializer should appear in the
meta
object rather than indata['attributes']
. Perhaps a field could be marked (with a kwarg or attribute on the serializer) as metadata so that the renderer knows to put it in the meta section?The text was updated successfully, but these errors were encountered: