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
Users should be able to configure API renderer_classes #6066
Comments
Thanks for filing an issue @narun4sk! How would you envision the api for setting “rendered_classes”? I think creating a subclass and overriding “rendered_classes” is the way you would do it in DRF as well. |
I've been looking to do something very similar myself, without copy-pasting all the Wagtail page-specific renderer logic into a subclass. Tried with JSON+HAL last week using https://github.com/seebass/drf-hal-json/ but just couldn't get it to work. I'm going to try with JSON:API next, but imagine I will encounter the same underlying modification problems (See: https://github.com/django-json-api/django-rest-framework-json-api). Maybe some docs that describe how developers might go about modifying the Wagtail-specific JSON format? That would help heaps :-) |
@marteinn in DRF we have this luxury in
IMO it's not too difficult to implement the same idea, isn't it? 🤔 Something like:
Then if I don't like the defaults I would just set:
|
Hi, any updates on that? It forces us to enable DRF browsable API, otherwise there's an error raised, see https://stackoverflow.com/questions/61961099/wagtail-api-v2-django-template-exceptions-templatedoesnotexist. It's somewhat contrary to documentation which states
https://docs.wagtail.org/en/stable/advanced_topics/api/v2/configuration.html#enable-the-app |
This helped me. Here is the simple code in
|
I've just hit this issue. I think as @m-aciek says, there's a documentation bug here. No code would need to change in Wagtail if we just documented that you need to subclass the various |
I agree with this. Marked the issue as such. PRs welcome ;) |
https://docs.wagtail.org/en/stable/advanced_topics/api/v2/configuration.html# although it, doesn't show how so i would just add a code snippet to show that |
- Update docs/advanced_topics/api/v2/configuration.md - Fixes wagtail#6066 - Fix up spelling of customise (UK English not US)
- Update docs/advanced_topics/api/v2/configuration.md - Fixes #6066 - Fix up spelling of customise (UK English not US)
Issue Summary
Users should be able to configure API
renderer_classes
, currently these are hardcoded to[JSONRenderer, BrowsableAPIRenderer]
:wagtail/wagtail/api/v2/views.py
Line 26 in 1958bba
Steps to Reproduce
Configure pages endpoint as usual, but do not include
rest_framework
in theINSTALLED_APPS
. Try to open configured endpoint in the browser, the app will throw an exception:Technical details
Currently I'm using this nasty trick:
The text was updated successfully, but these errors were encountered: