This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
# drf-nested-resources

This is a django rest framework extension to allow developers to create nested
resources.

## How to use

### Configuration of nested resources

For this example we are going to create a simple API with the following
endpoints:

/developers/
/developers/<id>
/developers/<id>/languages/
/developers/<id>/languages/<id>

First we start with the following Django models:

```python
from django.db.models.base import Model
from django.db.models.fields import CharField
from django.db.models.fields.related import ForeignKey


class Developer(Model):

name = CharField(max_length=20)


class ProgrammingLanguage(Model):

name = CharField(max_length=20)

author = ForeignKey(Developer, related_name='programming_languages')
```

We will have the two viewsets for both the `developers` and `languages` resource
collections.

```python
from rest_framework.viewsets import ModelViewSet
from drf_nested_resources.fields import HyperlinkedNestedModelSerializer


class _DeveloperSerializer(HyperlinkedNestedModelSerializer):

class Meta(object):

model = Developer

fields = ('url', 'name', 'programming_languages')


class DeveloperViewSet(ModelViewSet):

queryset = Developer.objects.all()

serializer_class = _DeveloperSerializer


class _ProgrammingLanguageSerializer(HyperlinkedNestedModelSerializer):

class Meta(object):

model = ProgrammingLanguage

fields = ('url', 'name', 'author')


class ProgrammingLanguageViewSet(ModelViewSet):

queryset = ProgrammingLanguage.objects.all()

serializer_class = _ProgrammingLanguageSerializer
```

The related fields in the ViewSets `author` and `programming_languages` should
follow the model representation so that `author` will give us a url for the
developer who wrote the ProgrammingLanguage and the `programming_languages`
should give us a list of urls for the ProgrammingLanguages that the Developer
wrote.

This is how you would generate the urlpatterns for them:

```python
_RESOURCES = [
Resource(
'developer',
'developers',
DeveloperViewSet,
[
NestedResource(
'language',
'languages',
ProgrammingLanguageViewSet,
parent_field_lookup='author',
)
],
),
]
urlpatterns = make_urlpatterns_from_resources(_RESOURCES)
```

For more examples of different relationships and authorization check the test
suite.

Changelog
=========

Version 1.1
-----------

Re-worked the mechanism for URL generation to support cross-linking resource
trees.

**Breaking change**: Any previous usage of many-to-many fields on variables
in the current request's URL will now break.


Version 1.0 Release Candidate 3
-------------------------------

Added proper support for namespaced URLs


Version 1.0 Release Candidate 1
-------------------------------

Added support for Django 1.10 and Rest Framework 3.4.3


Version 1.0 Beta 1 (unreleased)
-------------------------------

Initial release.
Release History

Release History

1.1.dev3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.dev2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.dev1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.dev0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0rc3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0rc2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0rc1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0b4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0b3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0b2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0b1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
drf_nested_resources-1.1.dev3-py3-none-any.whl (16.2 kB) Copy SHA256 Checksum SHA256 3.5 Wheel Oct 5, 2016
drf-nested-resources-1.1.dev3.tar.gz (11.2 kB) Copy SHA256 Checksum SHA256 Source Oct 5, 2016

Supported By

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