I turned the serve-method into an APIView #8374
Replies: 5 comments 5 replies
-
Is this similar to the approach taken in this blog post? https://dev.to/tommasoamici/headless-wagtail-what-are-the-pain-points-ji4 |
Beta Was this translation helpful? Give feedback.
-
Thanks! I like this approach! What do you think about making Wagtail look for a We could also provide a Also, I'm wondering why you had to add a custom serializer instead of using the PageSerializer in Wagtail? |
Beta Was this translation helpful? Give feedback.
-
can someone help me out? how can I get help on the problems that I am facing. |
Beta Was this translation helpful? Give feedback.
-
I think this might help for JSONRender. #api.py
|
Beta Was this translation helpful? Give feedback.
-
We have now raised an issue to try to define this pattern #11752 If someone is up for a pretty sizable contribution to Wagtail, it may be a good chance to get involved. This issue builds on the work done in #8386 and tries to define what other items would need to be addressed before we could look at this as being merged into the core code. |
Beta Was this translation helpful? Give feedback.
-
Could overriding the default serve-view in wagtail.core.views, attaching a django rest framework APIView decorator, cause major problems?
Since I use wagtail as a headless CMS I ended up overriding the serve method on all page models demonstrated here, rather than using the wagtail API v2:
https://docs.wagtail.org/en/stable/reference/pages/model_recipes.html
The reason being that I prefer not using the PagesAPIViewset and instead going for a route of custom serializers attached to various page models. However, doing so meant I now had to use JsonResponse(), because the DRF Response() requires the view to be an APIView doing the content negotiation (as far as I understand) which will attach the correct renderer.
Any alternative solutions / ideas / feedback? One of the reasons I wanted to use Response() was simply to allow debug toolbar to work, because I couldn't manage to figure out a middleware allowing that using JsonResponse. As of right now I really do feel like using wagtail headlessly is really fighting against my intuition a lot of times when working with pages.
Beta Was this translation helpful? Give feedback.
All reactions