Repository: django-json-api/django-rest-framework-json-api

Issue:
pip install djangorestframework-jsonapi fails
Running `pip install djangorestframework-jsonapi` fails as documented on Read the Docs. I believe the reason is that pip fails to recognize all the available version numbers appropriately.

According to the setuptools docs, the `-` in the version number makes the posted version a "post-release" number. https://pythonhosted.org/setuptools/setuptools.html#specifying-your-project-s-version

Here is the output I saw when I tried to run the command:

``` bash
$ pip install djangorestframework-jsonapi
Downloading/unpacking djangorestframework-jsonapi
  Could not find a version that satisfies the requirement djangorestframework-jsonapi \
(from versions: 2.0.0-alpha.1, 2.0.0-alpha.2, 2.0.0-alpha.3, 2.0.0-alpha, 2.0.0-beta.1)
Cleaning up...
No distributions matching the version for djangorestframework-jsonapi
Storing debug log for failure in /home/matt/.pip/pip.log
```

I don't know for sure, but my guess is that in the absence of an actual version (i.e., `2.0.0`), pip gives up when it only finds post release versions.

Resource name defined in view is not used in related relationships
Hello! I just want to describe something that has led me to confusion today.

The problem is this statement:

`
If you set the resource_name on a combination of model, serializer, or view in the same hierarchy, the name will be resolved as following: view > serializer > model. (Ex: A view resource_name will always override a resource_name specified on a serializer or model)
`

Say you have the following:

```
class PassengerSerializer(serializer.ModelSerializer):
   class Meta:
       resource_name = 'passenger-type-serializer'
       model = Passenger

class CarSerializer(serializer.ModelSerializer):
   passengers = ResourceRelatedField(many=True, source='passengers', read_only=True)

   include_serializers = dict(passengers=PassengerSerializer)
   class Meta:
       model = Car

class Passenger(viewsets.ReadOnlyModelViewSet):
   resource_name = 'passenger-type-view'
   serializer_class = PassengerSerializer

class Car(viewsets.ReadOnlyModelViewSet):
   serializer_class = CarSerializer

```

And you have a url configuration such that these resources are available through `/cars/` and `/passengers/`

Doing:
`GET /passengers/1/` will return `type=passenger-type-view`

while:

`GET /cars/1/?include=passengers` will return an `included` key with a list of resources with `type=passenger-type-serializer`

This is a bit inconsistent as depending from where you 'read' the passenger resource you might get different values for the `type` key.

To fix this, the `ResourceRelatedField` should be aware of the view the resource is exposed through, so that the `resource_name` value from the view could be read. This is not possible.

What do you think? Maybe it's not the best idea to allow people to define resource names in the views and that should just stay in the serializers/models.

Cheers!

`write_only` field included in response
Declaring a `write_only` on a serializer should not change the response. Currently, `write_only` fields are included in the response with a `null` value.



Discussion:
I should add that `pip install djangorestframework-jsonapi==2.0.0-beta.1` **does** work. Maybe the solution until the project comes out of beta with a `2.0.0` release is to document pip install with the specific version specifier.

The latest release is 2.0.0-beta.1, which pip will not automatically install because it is an unstable version. The older versions, 1.3.2 and below, are [not available on PyPI](https://pypi.python.org/simple/djangorestframework-jsonapi/) because it was previously called [`rest_framework_ember`](https://pypi.python.org/pypi/rest_framework_ember/).

You can still install the beta versions by explicitly specifying them.

``` bash
pip install djangorestframework-jsonapi==2.0.0-beta.1
```

alternatively, you can use the --pre flag

```
pip install --pre djangorestframework-jsonapi
```

At some point, `pip` fixed this problem in a newer version. I tried `pip install djangorestframework-jsonapi` on my Mac this morning and it worked without issue. My Mac has pip version `7.0.3`.

The command failed on the pip version that comes with Ubuntu 14.04. That version is `1.5.4`.




Resolving patch:
diff --git a/rest_framework_json_api/relations.py b/rest_framework_json_api/relations.py
--- a/rest_framework_json_api/relations.py
+++ b/rest_framework_json_api/relations.py
@@ -200,7 +200,7 @@ def many_init(cls, *args, **kwargs):
         for key in kwargs.keys():
             if key in ('model',) + MANY_RELATION_KWARGS:
                 list_kwargs[key] = kwargs[key]
-        return SerializerMethodResourceRelatedField(**list_kwargs)
+        return cls(**list_kwargs)
 
     def get_attribute(self, instance):
         # check for a source fn defined on the serializer instead of the model


Test patch: