Skip to content

Commit f723091

Browse files
committed
Fix example of explicit format URL.
The link is displayed in the tutorial as "http://example.com/api/items/4.json" but the hyperlink itself and what the example code actually works with are (in my opinion, less pretty) URLs like "http://example.com/api/items/4/.json".
1 parent 1d65378 commit f723091

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tutorial/2-requests-and-responses/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ <h2 id="pulling-it-all-together">Pulling it all together</h2>
473473
<p>This should all feel very familiar - it is not a lot different from working with regular Django views.</p>
474474
<p>Notice that we're no longer explicitly tying our requests or responses to a given content type. <code>request.data</code> can handle incoming <code>json</code> requests, but it can also handle other formats. Similarly we're returning response objects with data, but allowing REST framework to render the response into the correct content type for us.</p>
475475
<h2 id="adding-optional-format-suffixes-to-our-urls">Adding optional format suffixes to our URLs</h2>
476-
<p>To take advantage of the fact that our responses are no longer hardwired to a single content type let's add support for format suffixes to our API endpoints. Using format suffixes gives us URLs that explicitly refer to a given format, and means our API will be able to handle URLs such as <a href="http://example.com/api/items/4.json">http://example.com/api/items/4/.json</a>.</p>
476+
<p>To take advantage of the fact that our responses are no longer hardwired to a single content type let's add support for format suffixes to our API endpoints. Using format suffixes gives us URLs that explicitly refer to a given format, and means our API will be able to handle URLs such as <a href="http://example.com/api/items/4/.json">http://example.com/api/items/4/.json</a>.</p>
477477
<p>Start by adding a <code>format</code> keyword argument to both of the views, like so.</p>
478478
<pre><code>def snippet_list(request, format=None):
479479
</code></pre>
@@ -608,4 +608,4 @@ <h2 id="whats-next">What's next?</h2>
608608
</script>
609609
</body>
610610

611-
</html>
611+
</html>

0 commit comments

Comments
 (0)