mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
Move urls.py changes down and add necessary import
The previous location of editting urls.py did not allow migrations to be created and the default import needs to be modified
This commit is contained in:
parent
e3274af0ef
commit
44ae037e81
|
@ -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