From 930afc4968cb602a5ceff39f409cf8877cedde3e Mon Sep 17 00:00:00 2001 From: Alan Crosswell Date: Wed, 7 Feb 2018 10:04:45 -0500 Subject: [PATCH 1/6] Make documented example runserver work Resolves #410: docs/getting-started.md example doesn't work. --- docs/getting-started.md | 3 +-- example/requirements.txt | 11 +++++++++++ example/settings/dev.py | 4 ++++ example/urls.py | 10 +++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 4afcf2df..8d5e3030 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -70,7 +70,6 @@ From Source git clone https://github.com/django-json-api/django-rest-framework-json-api.git cd django-rest-framework-json-api - pip install -e . pip install -r example/requirements.txt django-admin.py runserver @@ -78,5 +77,5 @@ Browse to http://localhost:8000 ## Running Tests - python runtests.py + tox diff --git a/example/requirements.txt b/example/requirements.txt index a9660ae7..0fa77009 100644 --- a/example/requirements.txt +++ b/example/requirements.txt @@ -1,2 +1,13 @@ # Requirements specifically for the example app packaging +Django>=1.11 +django-debug-toolbar +django-polymorphic>=2.0 +djangorestframework +inflection +pluggy +py +pyparsing +pytz +six +sqlparse diff --git a/example/settings/dev.py b/example/settings/dev.py index d8b45738..a103d803 100644 --- a/example/settings/dev.py +++ b/example/settings/dev.py @@ -63,6 +63,10 @@ 'debug_toolbar.middleware.DebugToolbarMiddleware', ) +MIDDLEWARE = ( + 'debug_toolbar.middleware.DebugToolbarMiddleware', +) + INTERNAL_IPS = ('127.0.0.1', ) JSON_API_FORMAT_KEYS = 'camelize' diff --git a/example/urls.py b/example/urls.py index d6b58f3d..ad2d2e42 100644 --- a/example/urls.py +++ b/example/urls.py @@ -8,7 +8,8 @@ CommentViewSet, CompanyViewset, EntryViewSet, - ProjectViewset + ProjectViewset, + EntryRelationshipView, ) router = routers.DefaultRouter(trailing_slash=False) @@ -22,6 +23,13 @@ urlpatterns = [ url(r'^', include(router.urls)), + url(r'^entries/(?P[^/.]+)/relationships/(?P\w+)', + EntryRelationshipView.as_view(), + name='entry-relationships'), + url(r'^entries/(?P[^/.]+)/suggested/', + EntryViewSet.as_view({'get': 'list'}), + name='entry-suggested' + ), ] From cb5317d17fc2bdc81bfc02a7241bf58a1883344e Mon Sep 17 00:00:00 2001 From: Alan Crosswell Date: Wed, 7 Feb 2018 10:44:03 -0500 Subject: [PATCH 2/6] xGet the steps right in the documentation to run the example app. --- docs/getting-started.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 8d5e3030..372951fc 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -70,12 +70,17 @@ From Source git clone https://github.com/django-json-api/django-rest-framework-json-api.git cd django-rest-framework-json-api + python -m venv env + source env/bin/activate pip install -r example/requirements.txt - django-admin.py runserver + django-admin.py startproject example . + python manage.py migrate + python manage.py runserver Browse to http://localhost:8000 ## Running Tests + pip install tox tox From f596a110d46f94c91b9a9a12b6c2514b449c7bac Mon Sep 17 00:00:00 2001 From: Alan Crosswell Date: Fri, 9 Feb 2018 15:49:36 -0500 Subject: [PATCH 3/6] First attempt at for issue #410 didn't have includes sorted properly. - travis caught it. This time I've done the isort locally to confirm the order. - MIDDLEWARE_CLASSES was replaced by MIDDLEWARE as of Django 1.10 and, according to tox.ini, this is only testing >=1.11. --- example/settings/dev.py | 4 ---- example/urls.py | 23 ++++++++++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/example/settings/dev.py b/example/settings/dev.py index a103d803..61dfa443 100644 --- a/example/settings/dev.py +++ b/example/settings/dev.py @@ -59,10 +59,6 @@ PASSWORD_HASHERS = ('django.contrib.auth.hashers.UnsaltedMD5PasswordHasher', ) -MIDDLEWARE_CLASSES = ( - 'debug_toolbar.middleware.DebugToolbarMiddleware', -) - MIDDLEWARE = ( 'debug_toolbar.middleware.DebugToolbarMiddleware', ) diff --git a/example/urls.py b/example/urls.py index ad2d2e42..d51ae997 100644 --- a/example/urls.py +++ b/example/urls.py @@ -3,13 +3,17 @@ from rest_framework import routers from example.views import ( + AuthorRelationshipView, AuthorViewSet, + BlogRelationshipView, BlogViewSet, + CommentRelationshipView, CommentViewSet, CompanyViewset, - EntryViewSet, - ProjectViewset, EntryRelationshipView, + EntryViewSet, + NonPaginatedEntryViewSet, + ProjectViewset ) router = routers.DefaultRouter(trailing_slash=False) @@ -23,13 +27,22 @@ urlpatterns = [ url(r'^', include(router.urls)), - url(r'^entries/(?P[^/.]+)/relationships/(?P\w+)', - EntryRelationshipView.as_view(), - name='entry-relationships'), url(r'^entries/(?P[^/.]+)/suggested/', EntryViewSet.as_view({'get': 'list'}), name='entry-suggested' ), + url(r'^entries/(?P[^/.]+)/relationships/(?P\w+)', + EntryRelationshipView.as_view(), + name='entry-relationships'), + url(r'^blogs/(?P[^/.]+)/relationships/(?P\w+)', + BlogRelationshipView.as_view(), + name='blog-relationships'), + url(r'^comments/(?P[^/.]+)/relationships/(?P\w+)', + CommentRelationshipView.as_view(), + name='comment-relationships'), + url(r'^authors/(?P[^/.]+)/relationships/(?P\w+)', + AuthorRelationshipView.as_view(), + name='author-relationships'), ] From b067e63d0ba573c7c4f5be5554b513510797614f Mon Sep 17 00:00:00 2001 From: Alan Crosswell Date: Fri, 9 Feb 2018 16:07:57 -0500 Subject: [PATCH 4/6] missed a line which flake8 caught --- example/urls.py | 1 + 1 file changed, 1 insertion(+) diff --git a/example/urls.py b/example/urls.py index d51ae997..688ce70e 100644 --- a/example/urls.py +++ b/example/urls.py @@ -20,6 +20,7 @@ router.register(r'blogs', BlogViewSet) router.register(r'entries', EntryViewSet) +router.register(r'nopage-entries', NonPaginatedEntryViewSet, 'nopage-entry') router.register(r'authors', AuthorViewSet) router.register(r'comments', CommentViewSet) router.register(r'companies', CompanyViewset) From 7ca9d0112fed227bedec8a15b37730072236df5c Mon Sep 17 00:00:00 2001 From: Alan Crosswell Date: Sun, 18 Feb 2018 10:02:05 -0500 Subject: [PATCH 5/6] add back install of this package --- docs/getting-started.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/getting-started.md b/docs/getting-started.md index 372951fc..4b564418 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -73,6 +73,7 @@ From Source python -m venv env source env/bin/activate pip install -r example/requirements.txt + pip install -e . django-admin.py startproject example . python manage.py migrate python manage.py runserver From 926988ac6074cb307f418fa36af5fde37a9006a0 Mon Sep 17 00:00:00 2001 From: Alan Crosswell Date: Sun, 18 Feb 2018 13:26:10 -0500 Subject: [PATCH 6/6] add myself as an author as requested --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index a7efe523..6a90ff25 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,5 +1,6 @@ Adam Wróbel Adam Ziolkowski +Alan Crosswell Christian Zosel Greg Aker Jamie Bliss