From a9218e460f9569a630e0f86f38349cb3e73ca626 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 14 Jul 2016 12:44:13 +0100 Subject: [PATCH] Minor tutorial updates --- .../5-relationships-and-hyperlinked-apis.md | 6 +++--- docs/tutorial/7-schemas-and-client-libraries.md | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/tutorial/5-relationships-and-hyperlinked-apis.md b/docs/tutorial/5-relationships-and-hyperlinked-apis.md index 4b9347bfa..8cda09c62 100644 --- a/docs/tutorial/5-relationships-and-hyperlinked-apis.md +++ b/docs/tutorial/5-relationships-and-hyperlinked-apis.md @@ -18,7 +18,7 @@ Right now we have endpoints for 'snippets' and 'users', but we don't have a sing 'snippets': reverse('snippet-list', request=request, format=format) }) -Two things should be noticed here. First, we're using REST framework's `reverse` function in order to return fully-qualified URLs; second, URL patterns are identified by convenience names that we will declare later on in our `snippets/urls.py`. +Two things should be noticed here. First, we're using REST framework's `reverse` function in order to return fully-qualified URLs; second, URL patterns are identified by convenience names that we will declare later on in our `snippets/urls.py`. ## Creating an endpoint for the highlighted snippets @@ -80,7 +80,7 @@ We can easily re-write our existing serializers to use hyperlinking. In your `sn class Meta: model = Snippet - fields = ('url', 'highlight', 'owner', + fields = ('url', 'pk', 'highlight', 'owner', 'title', 'code', 'linenos', 'language', 'style') @@ -89,7 +89,7 @@ We can easily re-write our existing serializers to use hyperlinking. In your `sn class Meta: model = User - fields = ('url', 'username', 'snippets') + fields = ('url', 'pk', 'username', 'snippets') Notice that we've also added a new `'highlight'` field. This field is of the same type as the `url` field, except that it points to the `'snippet-highlight'` url pattern, instead of the `'snippet-detail'` url pattern. diff --git a/docs/tutorial/7-schemas-and-client-libraries.md b/docs/tutorial/7-schemas-and-client-libraries.md index 8d772a5bf..c2141489c 100644 --- a/docs/tutorial/7-schemas-and-client-libraries.md +++ b/docs/tutorial/7-schemas-and-client-libraries.md @@ -67,9 +67,13 @@ also supported. Now that our API is exposing a schema endpoint, we can use a dynamic client library to interact with the API. To demonstrate this, let's use the -Core API command line client. We've already installed the `coreapi` package -using `pip`, so the client tool should already be installed. Check that it -is available on the command line... +Core API command line client. + +The command line client is available as the `coreapi-cli` package: + + $ pip install coreapi-cli + +Now check that it is available on the command line... $ coreapi Usage: coreapi [OPTIONS] COMMAND [ARGS]... @@ -108,6 +112,7 @@ Let's try listing the existing snippets, using the command line client: [ { "url": "http://127.0.0.1:8000/snippets/1/", + "pk": 1, "highlight": "http://127.0.0.1:8000/snippets/1/highlight/", "owner": "lucy", "title": "Example", @@ -166,7 +171,7 @@ snippet: $ coreapi action snippets create --param title "Example" --param code "print('hello, world')" { "url": "http://127.0.0.1:8000/snippets/7/", - "id": 7, + "pk": 7, "highlight": "http://127.0.0.1:8000/snippets/7/highlight/", "owner": "lucy", "title": "Example",