kopia lustrzana https://github.com/wagtail/wagtail
Add docs example for how to configure API renderer_classes
- Update docs/advanced_topics/api/v2/configuration.md - Fixes #6066 - Fix up spelling of customise (UK English not US)pull/9868/head
rodzic
96b94d01d9
commit
529d2feb49
docs
advanced_topics/api/v2
releases
|
@ -87,6 +87,7 @@ Changelog
|
|||
* Docs: Fix incorrect example code for StreamField migration of `RichTextField` (Matt Westcott)
|
||||
* Docs: Document the policy needed to create invalidations in CloudFront (Jake Howard)
|
||||
* Docs: Document how to add permission restriction to a report view (Rishabh jain)
|
||||
* Docs: Add example for how to configure API `renderer_classes` (Aman Pandey)
|
||||
* Maintenance: Switch to using Willow instead of Pillow for images (Darrel O'Pry)
|
||||
* Maintenance: Remove unsquashed `testapp` migrations (Matt Westcott)
|
||||
* Maintenance: Upgrade to Node 18 for frontend build tooling (LB (Ben) Johnston)
|
||||
|
|
|
@ -44,7 +44,21 @@ Wagtail provides three endpoint classes you can use:
|
|||
- Images {class}`wagtail.images.api.v2.views.ImagesAPIViewSet`
|
||||
- Documents {class}`wagtail.documents.api.v2.views.DocumentsAPIViewSet`
|
||||
|
||||
You can subclass any of these endpoint classes to customize their functionality.
|
||||
You can subclass any of these endpoint classes to customise their functionality.
|
||||
For example, in this case if you need to change the `APIViewSet` by setting a desired renderer class:
|
||||
|
||||
```python
|
||||
from rest_framework.renderers import JSONRenderer
|
||||
|
||||
# ...
|
||||
|
||||
class CustomPagesAPIViewSet(PagesAPIViewSet):
|
||||
renderer_classes = [JSONRenderer]
|
||||
name = "pages"
|
||||
|
||||
api_router.register_endpoint("pages", ProdPagesAPIViewSet)
|
||||
```
|
||||
|
||||
Additionally, there is a base endpoint class you can use for adding different
|
||||
content types to the API: `wagtail.api.v2.views.BaseAPIViewSet`
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ model. You can read about configuration [here](apiv2_page_fields_configuration).
|
|||
```
|
||||
|
||||
This doesn't apply to images/documents as there is only one model exposed in
|
||||
those endpoints. But for projects that have customized image/document models,
|
||||
those endpoints. But for projects that have customised image/document models,
|
||||
the `api_fields` attribute can be used to export any custom fields into the
|
||||
API.
|
||||
|
||||
|
@ -523,7 +523,7 @@ the URL. For example:
|
|||
- Documents `/api/v2/documents/1/`
|
||||
|
||||
All exported fields will be returned in the response by default. You can use the
|
||||
`?fields` parameter to customize which fields are shown.
|
||||
`?fields` parameter to customise which fields are shown.
|
||||
|
||||
For example: `/api/v2/pages/1/?fields=_,title,body` will return just the
|
||||
`title` and `body` of the page with the id of 1.
|
||||
|
|
|
@ -169,6 +169,7 @@ This feature was developed by Matt Westcott, and sponsored by [YouGov](https://y
|
|||
* Pull out icon sprite setup function from inline script to its own TypeScript file & add unit tests (Loveth Omokaro)
|
||||
* Upgraded Transifex configuration to v3 (Loic Teixeira)
|
||||
* Replace repeated HTML `avatar` component with a template tag include `{% avatar ... %}` throughout the admin interface (Aman Pandey)
|
||||
* Add example for how to configure API `renderer_classes` (Aman Pandey)
|
||||
|
||||
## Upgrade considerations
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue