Skip to content

Issue 410 #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 18, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ 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 .
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work? I don't understand where the DJA package would be available to Python if it's not installed in editable mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's available because you are in the source tree for DJA so import rest_framework_json_api just works. I suppose retaining pip install -e . can't hurt. Pushing a new commit.

django-rest-framework-json-api$ tree -L 1
.
├── AUTHORS
├── CHANGELOG.md
├── LICENSE
├── MANIFEST.in
├── README.rst
├── docs
├── drf_example
├── env
├── example
├── manage.py
├── pytest.ini
├── requirements-development.txt
├── requirements.txt
├── rest_framework_json_api
├── setup.cfg
├── setup.py
└── tox.ini

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, neglected to answer the question: "Did you happen to run the steps you listed in Getting Started from a totally fresh clone to see if it would start the example app properly?"

Yes. Several times.

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

python runtests.py
pip install tox
tox

11 changes: 11 additions & 0 deletions example/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion example/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

PASSWORD_HASHERS = ('django.contrib.auth.hashers.UnsaltedMD5PasswordHasher', )

MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

Expand Down
22 changes: 22 additions & 0 deletions example/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,47 @@
from rest_framework import routers

from example.views import (
AuthorRelationshipView,
AuthorViewSet,
BlogRelationshipView,
BlogViewSet,
CommentRelationshipView,
CommentViewSet,
CompanyViewset,
EntryRelationshipView,
EntryViewSet,
NonPaginatedEntryViewSet,
ProjectViewset
)

router = routers.DefaultRouter(trailing_slash=False)

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)
router.register(r'projects', ProjectViewset)

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'),
]


Expand Down