You could create a View that extends APIView and return directly the
response on get method without Serializer.


There are ModelSerializer, ViewSet which are more related to Models, but
everything is not implemented on them, they extend other classes, so you
could go to the parent class and extend it.


Best regards,


--
Matheus (X-warrior) Bratfisch.
http://matbra.com

On Mon, Jun 20, 2016 at 11:25 PM, 'Abraham Varricatt' via Django REST
framework <django-rest-framework@googlegroups.com> wrote:

> Hello,
>
> Is it possible to use Django Rest Framework (DRF) for something other than
> models? Here's a trivial example,
>
> To make an API end point which returns the current server time (in JSON
> format, eg: {"current_time": "XYZ"}). It can accept a string to indicate
> timezone, and must accept both GET and POST.
>
> I can figure out how to do the above without DRF using regular Django urls
> and views. What I can't figure out is how to use DRF for the same.
>
> From the docs, it looks best to use routers when making a DRF end-point.
> Which means I need a structure like this,
>
> urls.py <-> router <-> Viewset <-> Serializer
>
> But as I understand Serilizers (
> http://www.django-rest-framework.org/api-guide/serializers/ ), they can
> only be used for complex models or querysets - which is not what I need.
>
> I feel like I'm mis-understanding something about DRF. Help please?
>
> Puzzled,
> Abraham V.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-rest-framework+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to