@@ -36,10 +36,15 @@ per request via the `PAGINATE_BY_PARAM` query parameter (`page_size` by default)
3636
3737### Setting the resource_name
3838
39- You may manually set the ` resource_name ` property on views or serializers to
40- specify the ` type ` key in the json output. It is automatically set for you as the
41- plural of the view or model name except on resources that do not subclass
39+ You may manually set the ` resource_name ` property on views, serializers, or
40+ models to specify the ` type ` key in the json output. In the case of setting the
41+ ` resource_name ` property for models you must include the property inside a
42+ ` JSONAPIMeta ` class on the model. It is automatically set for you as the plural
43+ of the view or model name except on resources that do not subclass
4244` rest_framework.viewsets.ModelViewSet ` :
45+
46+
47+ Example - ` resource_name ` on View:
4348``` python
4449class Me (generics .GenericAPIView ):
4550 """
@@ -56,6 +61,23 @@ If you set the `resource_name` property on the object to `False` the data
5661will be returned without modification.
5762
5863
64+ Example - ` resource_name ` on Model:
65+ ``` python
66+ class Me (models .Model ):
67+ """
68+ A simple model
69+ """
70+ name = models.CharField(max_length = 100 )
71+
72+ class JSONAPIMeta :
73+ resource_name = " users"
74+ ```
75+ If you set the ` resource_name ` on a combination of model, serializer, or view
76+ in the same hierarchy, the name will be resolved as following: view >
77+ serializer > model. (Ex: A view ` resource_name ` will always override a
78+ ` resource_name ` specified on a serializer or model)
79+
80+
5981### Inflecting object and relation keys
6082
6183This package includes the ability (off by default) to automatically convert json
0 commit comments