Nesting DRF ViewSets

26 views
Skip to first unread message

Ryan Sears

unread,
Nov 17, 2016, 3:10:29 AM11/17/16
to Django REST framework
Hi folks!

I've got a question on nesting viewsets properly to have different permission classes/contexts. Any extra eyes would be greatly appreciated, as it's been open for about a week and I'm not confident that any of the solutions proposed are the "right" way to accomplish what I'm trying to do! 

http://stackoverflow.com/questions/40455229/nesting-viewset-routes-in-drf

Cheers,
Ryan

Xavier Ordoquy

unread,
Nov 17, 2016, 4:48:04 AM11/17/16
to django-res...@googlegroups.com
Hi,
We usually advice not to nested routes.
ReST API expose resources. Nesting routes means that you don’t have direct access to those resources which makes things more complex for the client, breaks automated generations and duplicates entry points for the same resource (which is similar to breaking DRY). There are probably other points too.

As mentioned on SO,  https://github.com/alanjds/drf-nested-routers should do. As you think it’s overkill, you may want to look at the source and take whatever you want if you still want to go in that direction.

Regards,
Xavier,
Linovia.
Reply all
Reply to author
Forward
0 new messages