diff options
| author | Tom Christie | 2014-11-03 11:21:29 +0000 | 
|---|---|---|
| committer | Tom Christie | 2014-11-03 11:21:29 +0000 | 
| commit | dd14c6c88ba210bac8349041b8db486576539249 (patch) | |
| tree | 81b1e22fb8080a8d3915ae6a5db95edf87a3bfb6 /tutorial/1-serialization.html | |
| parent | ce165805481988e95887bf62c45cd616af5bba0f (diff) | |
| download | django-rest-framework-dd14c6c88ba210bac8349041b8db486576539249.tar.bz2 | |
Latest docs release
Diffstat (limited to 'tutorial/1-serialization.html')
| -rw-r--r-- | tutorial/1-serialization.html | 13 | 
1 files changed, 7 insertions, 6 deletions
| diff --git a/tutorial/1-serialization.html b/tutorial/1-serialization.html index 9c50a584..94145642 100644 --- a/tutorial/1-serialization.html +++ b/tutorial/1-serialization.html @@ -256,9 +256,9 @@ cd tutorial  )  </code></pre>  <p>We also need to wire up the root urlconf, in the <code>tutorial/urls.py</code> file, to include our snippet app's URLs.</p> -<pre class="prettyprint lang-py"><code>urlpatterns = patterns('', +<pre class="prettyprint lang-py"><code>urlpatterns = [      url(r'^', include('snippets.urls')), -) +]  </code></pre>  <p>Okay, we're ready to roll.</p>  <h2 id="creating-a-model-to-work-with">Creating a model to work with</h2> @@ -459,11 +459,12 @@ def snippet_detail(request, pk):  </code></pre>  <p>Finally we need to wire these views up.  Create the <code>snippets/urls.py</code> file:</p>  <pre class="prettyprint lang-py"><code>from django.conf.urls import patterns, url +from snippets import views -urlpatterns = patterns('snippets.views', -    url(r'^snippets/$', 'snippet_list'), -    url(r'^snippets/(?P<pk>[0-9]+)/$', 'snippet_detail'), -) +urlpatterns = [ +    url(r'^snippets/$', views.snippet_list), +    url(r'^snippets/(?P<pk>[0-9]+)/$', views.snippet_detail), +]  </code></pre>  <p>It's worth noting that there are a couple of edge cases we're not dealing with properly at the moment.  If we send malformed <code>json</code>, or if a request is made with a method that the view doesn't handle, then we'll end up with a 500 "server error" response.  Still, this'll do for now.</p>  <h2 id="testing-our-first-attempt-at-a-web-api">Testing our first attempt at a Web API</h2> | 
