diff options
| author | Tom Christie | 2011-05-04 09:21:17 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-05-04 09:21:17 +0100 |
| commit | d373b3a067796b8e181be9368fa24e89c572c45e (patch) | |
| tree | eec24eb8f8813ce959511c3572a54c5ee645e227 /examples | |
| parent | 8756664e064a18afc4713d921c318cd968f18433 (diff) | |
| download | django-rest-framework-d373b3a067796b8e181be9368fa24e89c572c45e.tar.bz2 | |
Decouple views and resources
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/modelresourceexample/views.py | 6 | ||||
| -rw-r--r-- | examples/urls.py | 15 |
2 files changed, 5 insertions, 16 deletions
diff --git a/examples/modelresourceexample/views.py b/examples/modelresourceexample/views.py index 07f50b65..5495a293 100644 --- a/examples/modelresourceexample/views.py +++ b/examples/modelresourceexample/views.py @@ -1,15 +1,15 @@ -from djangorestframework.modelresource import ModelResource, RootModelResource +from djangorestframework.modelresource import InstanceModelResource, ListOrCreateModelResource from modelresourceexample.models import MyModel FIELDS = ('foo', 'bar', 'baz', 'absolute_url') -class MyModelRootResource(RootModelResource): +class MyModelRootResource(ListOrCreateModelResource): """A create/list resource for MyModel. Available for both authenticated and anonymous access for the purposes of the sandbox.""" model = MyModel fields = FIELDS -class MyModelResource(ModelResource): +class MyModelResource(InstanceModelResource): """A read/update/delete resource for MyModel. Available for both authenticated and anonymous access for the purposes of the sandbox.""" model = MyModel diff --git a/examples/urls.py b/examples/urls.py index 7cb5e7ce..cf4d4042 100644 --- a/examples/urls.py +++ b/examples/urls.py @@ -2,11 +2,8 @@ from django.conf.urls.defaults import patterns, include, url from django.conf import settings from sandbox.views import Sandbox -urlpatterns = patterns('djangorestframework.views', - (r'robots.txt', 'deny_robots'), - +urlpatterns = patterns('', (r'^$', Sandbox.as_view()), - (r'^resource-example/', include('resourceexample.urls')), (r'^model-resource-example/', include('modelresourceexample.urls')), (r'^mixin/', include('mixin.urls')), @@ -14,14 +11,6 @@ urlpatterns = patterns('djangorestframework.views', (r'^pygments/', include('pygments_api.urls')), (r'^blog-post/', include('blogpost.urls')), - (r'^accounts/login/$', 'api_login'), - (r'^accounts/logout/$', 'api_logout'), + (r'^', include('djangorestframework.urls')), ) -# Only serve favicon in production because otherwise chrome users will pretty much -# permanantly have the django-rest-framework favicon whenever they navigate to -# 127.0.0.1:8000 or whatever, which gets annoying -if not settings.DEBUG: - urlpatterns += patterns('djangorestframework.views', - (r'favicon.ico', 'favicon'), - ) |
