Closed MoRadwan74 closed 2 years ago
wagtail-generic-chooser doesn't currently provide any mechanism for this, no. The base ChooserBlock implementation provided by Wagtail defines various data conversions that only make sense for Django models - e.g. to turn the ID as stored in the streamfield's JSON representation into an object it's possible to use target_model.objects.get(pk=...)
. For a REST API endpoint, you'd need to come up with new definitions for these data conversions. It ought to be possible to do this by subclassing FieldBlock, but this process isn't well-documented at the moment.
Okay, thanks for the info, @gasman. I will close this one.
Hello there,
I want to extend the ChooserBlock model not with a
target_model
, but with an JSON object returned from an DRF-based API request. Simply, I have a list of JSON objects that I want to be able to add it to the ChooserBlock and the user is able to select one of them in wagtail admin.Can this package provide me this? It was promising when I read this line in the README:
But I got lost between the views and widgets here as it seems this package is intended to control the DRF API provided by wagtail and not an external REST API endpoint as mentioned in the quote above.
Any help would be very appreciated.