Skip to content

Commit

Permalink
📝Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yezyilomo committed May 24, 2019
1 parent 81a40e6 commit 92ecb68
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class UserViewSet(DynamicFieldsMixin, viewsets.ModelViewSet):

A regular request returns all fields specified on DRF serializer, in fact **django-restql** doesn't handle this request at all:

```GET /users```
`GET /users`

``` json
[
Expand All @@ -54,7 +54,7 @@ A regular request returns all fields specified on DRF serializer, in fact **djan

**django-restql** handle all GET requests with `query` parameter, this parameter is the one used to pass all fields to be included on a response. For example to select `id` and `username` fields from `user` model, send a request with a ` query` parameter as shown below.

`GET /users/?query=["id", "username"]`
`GET /users/?query={id, username}`

```json
[
Expand All @@ -68,7 +68,7 @@ A regular request returns all fields specified on DRF serializer, in fact **djan

If a query contains nested field, **django-restql** will return its id or array of ids for the case of nested iterable field(one2many or many2many). For example on a request below `location` is a flat nested field(many2one) and `groups` is an iterable nested field(one2many or many2many).

`GET /users/?query=["id", "username", "location", "groups"]`
`GET /users/?query={id, username, location, group}`

```json
[
Expand All @@ -84,7 +84,7 @@ If a query contains nested field, **django-restql** will return its id or array

**django-restql** support querying both flat and nested resources, so you can expand or query nested fields at any level as long as your field is defined as nested field on a serializer. For example you can query a country and region field from location.

`GET /users/?query=["id", "username", {"location": ["country", "region"]}]`
`GET /users/?query={id, username, location{country, region}}`

```json
[
Expand All @@ -102,7 +102,7 @@ If a query contains nested field, **django-restql** will return its id or array

**django-restql** got your back on expanding or querying iterable nested fields too. For example if you want to expand `groups` field into `id` and `name`, here is how you would do it.

`GET /users/?query=["id", "username", {"groups": [ "id", "name" ]}]`
`GET /users/?query={id, username, groups{id, name}}`

```json
[
Expand Down Expand Up @@ -137,7 +137,7 @@ If a query contains nested field, **django-restql** will return its id or array
```
Now you can use this Mixin on your view and use the name `your_favourite_name` as your parameter. E.g

`GET /users/?your_favourite_name=["id", "username"]`
`GET /users/?your_favourite_name={id, username}`

* Customize how it filter fields to include in a response.
You can do this by inheriting DynamicFieldsMixin and override `list` and `retrieve` methods as shown below.
Expand Down

0 comments on commit 92ecb68

Please sign in to comment.