Hi,

You may also want to look at 
https://medium.com/django-rest-framework/django-rest-framework-viewset-when-you-don-t-have-a-model-335a0490ba6f
It explains how to use a Viewset without models.

Regards,
Xavier,
Linovia.


> Le 21 juin 2016 à 04:25, 'Abraham Varricatt' via Django REST framework 
> <django-rest-framework@googlegroups.com> a écrit :
> 
> 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 
> <mailto:django-rest-framework+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <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.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to