[PATCH 16/51] settings: Add Django REST framework to the project
Damien Lespiau
damien.lespiau at intel.com
Sat Sep 12 01:54:49 AEST 2015
Let's try to do have a more modern approach to this web thing. Having a
separate API returning some JSON ensures a nice split between data and
UI. This API can be both used withing the HTML pages, loading/updating
data with AJAX, and from any other kind of client (say, it could replace
the XML-RPC API patchwork currently has).
But for now, let's experiment on Series.
Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
docs/requirements-base.txt | 2 ++
patchwork/settings/base.py | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/docs/requirements-base.txt b/docs/requirements-base.txt
index 58b34ec..748b399 100644
--- a/docs/requirements-base.txt
+++ b/docs/requirements-base.txt
@@ -1,2 +1,4 @@
MySQL-python==1.2.5
python-dateutil==1.5
+djangorestframework>=2.4.8,<3.0.0
+drf-nested-routers
diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py
index 5b40bcb..8f4791c 100644
--- a/patchwork/settings/base.py
+++ b/patchwork/settings/base.py
@@ -24,6 +24,7 @@ INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.staticfiles',
'patchwork',
+ 'rest_framework',
]
# HTTP
@@ -89,6 +90,17 @@ STATICFILES_DIRS = [
os.path.join(ROOT_DIR, 'htdocs'),
]
+#
+# REST framework
+
+REST_FRAMEWORK = {
+ # Use Django's standard `django.contrib.auth` permissions,
+ # or allow read-only access for unauthenticated users.
+ 'DEFAULT_PERMISSION_CLASSES': [
+ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
+ ]
+}
+
#
# Patchwork settings
--
2.1.0
More information about the Patchwork
mailing list