Context Aware Browsable API Rendering in Django REST -
Context Aware Browsable API Rendering in Django REST -
is there easy way create hyperlinks in django rest browsable api, not in other api renderings. clear render fields hyperlinks when viewing page through browsable api render text component when rendering through json.
an illustration of utilize case render pk in list view hyperlink detail view (similar to: http://chibisov.github.io/drf-extensions/docs/#resourceurifield) when viewing list view in browsable api mode. in regular json get, render pk.
my hope create browsable api more useable/navigable when accessing through browser.
is in way relevant: http://www.django-rest-framework.org/api-guide/renderers#browsableapirenderer?
more generally, there anyway set excludes dependent on rendering mode?
you can homecoming different serializers in different context, overriding get_serializer
method on genericapiview
or of subclasses.
something right...
def get_serializer(self, ...): if self.request.accepted_renderer.format == 'api': # browsable style else: # standard style
if code behaviour mixin class you'd able reuse throughout views.
django django-rest-framework
Comments
Post a Comment