Skip to content

Commit

Permalink
Enabling Wagtail v2 API (Headless CMS)
Browse files Browse the repository at this point in the history
  • Loading branch information
KalobTaulien committed Mar 19, 2019
1 parent f942392 commit 8988bd8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mysite/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from wagtail.api.v2.endpoints import PagesAPIEndpoint
from wagtail.api.v2.router import WagtailAPIRouter
from wagtail.images.api.v2.endpoints import ImagesAPIEndpoint
from wagtail.documents.api.v2.endpoints import DocumentsAPIEndpoint

api_router = WagtailAPIRouter('wagtailapi')

api_router.register_endpoint('pages', PagesAPIEndpoint)
api_router.register_endpoint('images', ImagesAPIEndpoint)
api_router.register_endpoint('documents', DocumentsAPIEndpoint)
2 changes: 2 additions & 0 deletions mysite/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'wagtail.api.v2',

'modelcluster',
'taggit',
Expand All @@ -63,6 +64,7 @@

'captcha',
'wagtailcaptcha',
'rest_framework',
]

MIDDLEWARE = [
Expand Down
4 changes: 4 additions & 0 deletions mysite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from search import views as search_views

from .api import api_router


urlpatterns = [
url(r'^django-admin/', admin.site.urls),
Expand All @@ -19,6 +21,8 @@

url(r'^search/$', search_views.search, name='search'),

url(r'^api/v2/', api_router.urls),

url(r'^sitemap.xml$', sitemap),
# For anything not caught by a more specific rule above, hand over to
# Wagtail's page serving mechanism. This should be the last pattern in
Expand Down

1 comment on commit 8988bd8

@KalobTaulien
Copy link
Member Author

Choose a reason for hiding this comment

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

Please sign in to comment.