mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-11-04 09:57:55 +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',
 | 
					        '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.
 | 
					Okay, we're ready to roll.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Creating a model to work with
 | 
					## Creating a model to work with
 | 
				
			||||||
| 
						 | 
					@ -300,6 +294,14 @@ Finally we need to wire these views up.  Create the `snippets/urls.py` file:
 | 
				
			||||||
        url(r'^snippets/(?P<pk>[0-9]+)/$', views.snippet_detail),
 | 
					        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.
 | 
					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.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Testing our first attempt at a Web API
 | 
					## Testing our first attempt at a Web API
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user