Repository: django-json-api/django-rest-framework-json-api

Issue:
docs/getting-started.md example doesn't work.
Following the [running the example app](https://github.com/django-json-api/django-rest-framework-json-api/blob/master/docs/getting-started.md#running-the-example-app) instructions results in several errors:
- `runtests.py` is missing: not found anywhere in the repo. Did you mean `django-admin.py test`?
- `django-admin.py runserver` errors out with:
```
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
```
Trying to set `DJANGO_SETTINGS_MODULE` complains about other missing stuff:
```
ModuleNotFoundError: No module named 'polymorphic'
```
Here's what `pip freeze` shows:
```
Django==2.0.2
djangorestframework==3.7.7
-e git+https://github.com/django-json-api/django-rest-framework-json-api.git@c5d34e2ea67bab8a4e9570f54779911570f24c83#egg=djangorestframework_jsonapi
inflection==0.3.1
packaging==16.8
pyparsing==2.2.0
pytz==2017.3
six==1.11.0
```
I attempted these fixes:
```bash
pip install django-polymorphic
pip install django-debug_toolbar
export DJANGO_SETTINGS_MODULE=example.settings.dev
django-admin.py runserver
...
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
?: debug_toolbar.middleware.DebugToolbarMiddleware is missing from MIDDLEWARE.
	HINT: Add debug_toolbar.middleware.DebugToolbarMiddleware to MIDDLEWARE.
```
which is weird since:
```bash
grep -nr debug_toolbar.middleware.DebugToolbarMiddleware .
...
./example/settings/dev.py:63:    'debug_toolbar.middleware.DebugToolbarMiddleware',
```
I've successfully used most of DJA based on [usage.md](https://github.com/django-json-api/django-rest-framework-json-api/blob/master/docs/usage.md) but was looking for some examples, especially for resource-related fields and figured the example app would be a good place to start.

Happy to try and submit a PR with improved documentation if you can provide some guidance on what's supposed to be there. Thanks!


Discussion:
I think the example app doesn't get a lot of love. Unfortunately, I don't have any immediate answers for you. The test suite runs with `python setup.py test` in Tox so that might be a good first thing to try and replicate.

Anything that makes the example app more runnable for others would appreciated. Thanks!

Resolving patch:
diff --git a/example/settings/dev.py b/example/settings/dev.py
--- a/example/settings/dev.py
+++ b/example/settings/dev.py
@@ -59,7 +59,7 @@
 
 PASSWORD_HASHERS = ('django.contrib.auth.hashers.UnsaltedMD5PasswordHasher', )
 
-MIDDLEWARE_CLASSES = (
+MIDDLEWARE = (
     'debug_toolbar.middleware.DebugToolbarMiddleware',
 )
 
diff --git a/example/urls.py b/example/urls.py
--- a/example/urls.py
+++ b/example/urls.py
@@ -3,11 +3,16 @@
 from rest_framework import routers
 
 from example.views import (
+    AuthorRelationshipView,
     AuthorViewSet,
+    BlogRelationshipView,
     BlogViewSet,
+    CommentRelationshipView,
     CommentViewSet,
     CompanyViewset,
+    EntryRelationshipView,
     EntryViewSet,
+    NonPaginatedEntryViewSet,
     ProjectViewset
 )
 
@@ -15,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)
@@ -22,6 +28,22 @@
 
 urlpatterns = [
     url(r'^', include(router.urls)),
+    url(r'^entries/(?P<entry_pk>[^/.]+)/suggested/',
+        EntryViewSet.as_view({'get': 'list'}),
+        name='entry-suggested'
+        ),
+    url(r'^entries/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)',
+        EntryRelationshipView.as_view(),
+        name='entry-relationships'),
+    url(r'^blogs/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)',
+        BlogRelationshipView.as_view(),
+        name='blog-relationships'),
+    url(r'^comments/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)',
+        CommentRelationshipView.as_view(),
+        name='comment-relationships'),
+    url(r'^authors/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)',
+        AuthorRelationshipView.as_view(),
+        name='author-relationships'),
 ]
 
 


Test patch: