mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Merge pull request #3747 from pbaehr/master
Move urls.py changes down and add necessary import
This commit is contained in:
commit
00ead782d4
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user