aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSébastien Piquemal2012-02-02 08:39:15 +0200
committerSébastien Piquemal2012-02-02 08:39:15 +0200
commit5f59d90645dfddc293bbbbc4ca9b4c3f3125b590 (patch)
treeaa3d091a1f61f5717f7f1a9e96334308bb13c7d9 /examples
parent152c385f4de37558fe4e522abad5b97f0cf7ddce (diff)
parent894f63259880252ed5317ce485eb13c4429b65c1 (diff)
downloaddjango-rest-framework-5f59d90645dfddc293bbbbc4ca9b4c3f3125b590.tar.bz2
merged with trunk's master
Diffstat (limited to 'examples')
-rw-r--r--examples/permissionsexample/views.py23
-rw-r--r--examples/requirements-epio.txt2
-rw-r--r--examples/settings.py13
-rw-r--r--examples/urls.py2
4 files changed, 24 insertions, 16 deletions
diff --git a/examples/permissionsexample/views.py b/examples/permissionsexample/views.py
index 3f71e67b..86f458f8 100644
--- a/examples/permissionsexample/views.py
+++ b/examples/permissionsexample/views.py
@@ -2,14 +2,23 @@ from djangorestframework.views import View
from djangorestframework.permissions import PerUserThrottling, IsAuthenticated
from django.core.urlresolvers import reverse
+
class PermissionsExampleView(View):
"""
A container view for permissions examples.
"""
def get(self, request):
- return [{'name': 'Throttling Example', 'url': reverse('throttled-resource')},
- {'name': 'Logged in example', 'url': reverse('loggedin-resource')},]
+ return [
+ {
+ 'name': 'Throttling Example',
+ 'url': reverse('throttled-resource')
+ },
+ {
+ 'name': 'Logged in example',
+ 'url': reverse('loggedin-resource')
+ },
+ ]
class ThrottlingExampleView(View):
@@ -20,7 +29,7 @@ class ThrottlingExampleView(View):
throttle will be applied until 60 seconds have passed since the first request.
"""
- permissions = ( PerUserThrottling, )
+ permissions = (PerUserThrottling,)
throttle = '10/min'
def get(self, request):
@@ -29,13 +38,15 @@ class ThrottlingExampleView(View):
"""
return "Successful response to GET request because throttle is not yet active."
+
class LoggedInExampleView(View):
"""
You can login with **'test', 'test'.** or use curl:
-
+
`curl -X GET -H 'Accept: application/json' -u test:test http://localhost:8000/permissions-example`
- """
+ """
permissions = (IsAuthenticated, )
+
def get(self, request):
- return 'Logged in or not?'
+ return 'You have permission to view this resource'
diff --git a/examples/requirements-epio.txt b/examples/requirements-epio.txt
index 76ab5bd2..b4962676 100644
--- a/examples/requirements-epio.txt
+++ b/examples/requirements-epio.txt
@@ -1,3 +1,3 @@
Pygments==1.4
Markdown==2.0.3
-djangorestframework
+git+git://github.com/tomchristie/django-rest-framework.git
diff --git a/examples/settings.py b/examples/settings.py
index 3b024ea1..082ba9d3 100644
--- a/examples/settings.py
+++ b/examples/settings.py
@@ -53,16 +53,10 @@ MEDIA_ROOT = os.path.join(os.getenv('EPIO_DATA_DIRECTORY', '.'), 'media')
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
# NOTE: None of the djangorestframework examples serve media content via MEDIA_URL.
-MEDIA_URL = ''
+MEDIA_URL = '/uploads/'
+
+STATIC_URL = '/static/'
-# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
-# trailing slash.
-# Examples: "http://foo.com/media/", "/media/".
-# NOTE: djangorestframework does not require the admin app to be installed,
-# but it does require the admin media be served. Django's test server will do
-# this for you automatically, but in production you'll want to make sure you
-# serve the admin media from somewhere.
-ADMIN_MEDIA_PREFIX = '/static/admin'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 't&9mru2_k$t8e2-9uq-wu2a1)9v*us&j3i#lsqkt(lbx*vh1cu'
@@ -102,6 +96,7 @@ INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
+ 'django.contrib.staticfiles',
'django.contrib.messages',
'djangorestframework',
diff --git a/examples/urls.py b/examples/urls.py
index b71c0a20..402fde28 100644
--- a/examples/urls.py
+++ b/examples/urls.py
@@ -1,6 +1,7 @@
from django.conf.urls.defaults import patterns, include, url
from django.conf import settings
from sandbox.views import Sandbox
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = patterns('',
(r'^$', Sandbox.as_view()),
@@ -16,3 +17,4 @@ urlpatterns = patterns('',
(r'^', include('djangorestframework.urls')),
)
+urlpatterns += staticfiles_urlpatterns()