Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Nested resources for the Django Rest Framework

Project Description

# django-rest-framework-nested
Work in progress for nested support for django-rest-framework


```pip install django-rest-framework-nested```


'DEFAULT_FILTER_BACKENDS': ('rest_framework_nested_test.filters.NestedFilterBackend',)

from rest_framework import routers
from rest_framework_nested import routers as nested_routers
from django.conf.urls import url, include, patterns
import views

api_router = routers.DefaultRouter()

api_router.register(r'parent', views.ParentViewSet)
api_parent_router = nested_routers.NestedSimpleRouter(api_router, 'parent', lookup='parent')
api_parent_router.register(r'child', views.ChildViewSet)

urlpatterns = patterns(''
url(r'^api/', include(api_router.urls)),

from rest_framework import serializers
from rest_framework_nested import serializers as nested_serializers
import models

class ChildSerializer(nested_serializers.NestedHyperlinkedModelSerializer):
class Meta:
model = models.Child

class ParentSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.Parent

values = ChildSerializer(many=True, required=False, read_only=True)

from rest_framework import viewsets
import models, serializers

class ParentViewSet(viewsets.ModelViewSet):
API endpoint that allows Parent to be viewed or edited.
queryset = models.Parent.objects.get_queryset()
serializer_class = serializers.ParentSerializer

class ChildViewSet(viewsets.ModelViewSet):
API endpoint that allows Child to be viewed or edited.
queryset = models.Child.objects.get_queryset()
serializer_class = serializers.ChildSerializer


This package is licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
and can undestand more at on the
sidebar notes.

Apache Licence v2.0 is a MIT-like licence. This means, in plain English:
- Its trully open source
- You can use it as you wish, for money or not
- You can sublicence it (change the licence!!)
- This way, you can even use it on your closed-source project
As long as:
- You cannot use the authors name, logos, etc, to endorse a project
- You keep the authors copyright notices where this code got used, even on your closed-source project
(come on, even Microsoft kept BSD notices on Windows about its TCP/IP stack :P)

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(3.3 kB) Copy SHA256 Hash SHA256
Source None May 14, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting