drf-nested-routers
drf-nested-routers copied to clipboard
Suggested view.py documentation change & format_suffix_patterns
I'm relatively new to DRF. Thanks for this extension as it's very helpful. A suggestion for the documentation:
# views.py
class NameserverViewSet(viewsets.ViewSet):
def list(self, request, domain_pk=None, *args, **kwargs):
self.queryset = Nameserver.objects.filter(domain=domain_pk)
(...)
return super(NameserverViewSet, self).list(request, context={'request': request}, *args, **kwargs)
def retrieve(self, request, pk=None, domain_pk=None, *args, **kwargs):
nameservers = Nameserver.objects.filter(pk=pk, domain=domain_pk)
(...)
return super(NameserverViewSet, self).retrieve(request, context={'request': request}, *args, **kwargs)
for those of us that would rather take advantage of things like permissions and pagination out of the box. I ended up implementing those manually then kicked myself when I realized the above was much better.
Which leads me to the question: is anyone using format_suffix_patterns with drf-nested-routers? If so, what's the magic?
I guess the magic is partially explained on #91. Please take a look