Merge pull request #3747 from pbaehr/master

Move urls.py changes down and add necessary import
This commit is contained in:
Xavier Ordoquy 2015-12-16 18:22:26 +01:00
commit 00ead782d4

View File

@ -48,12 +48,6 @@ We'll need to add our new `snippets` app and the `rest_framework` app to `INSTAL
'snippets',
)
We also need to wire up the root urlconf, in the `tutorial/urls.py` file, to include our snippet app's URLs.
urlpatterns = [
url(r'^', include('snippets.urls')),
]
Okay, we're ready to roll.
## Creating a model to work with
@ -299,6 +293,14 @@ Finally we need to wire these views up. Create the `snippets/urls.py` file:
url(r'^snippets/$', views.snippet_list),
url(r'^snippets/(?P<pk>[0-9]+)/$', views.snippet_detail),
]
We also need to wire up the root urlconf, in the `tutorial/urls.py` file, to include our snippet app's URLs.
from django.conf.urls import url, include
urlpatterns = [
url(r'^', include('snippets.urls')),
]
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 `json`, 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.