An application to load django CMS pages in a client application.
djangocms-rest-view uses Django REST framework to serve django CMS pages through a REST API
Editing must still be done the "traditional" way
- pip install djangocms-rest-view
Edit
INSTALLED_APPS
:INSTALLED_APPS = [ ... 'rest_framework', 'djangocms_rest_view', ... ]
Edit
urls.py
:urlpatterns = [ ... url(r'^api/', include('djangocms_rest_view.urls')), ... ]
- That's all!
The REST view of the pages will be available at http://example.com/api/
A sample Angular JS client is provided within the project.
To start exploring djangocms-rest view, you can install it and browse the website:
Edit
INSTALLED_APPS
:INSTALLED_APPS = [ ... 'djangocms_rest_view.client', ... ]
Edit
urls.py
:urlpatterns = [ ... url(r'^rest/', include('djangocms_rest_view.client.urls')), ... ]
the Angular client will be available at http://example.com/rest/
- Install dependencies according to the application bower.json: https://gitix.iast.it/opensource/djangocms-rest-view/blob/master/bower.json
example:
- Copy dependencies in project
bower.json
run bower:
bower install
The sample client uses a dedicated base page to load all the default styles etc needed to render your content. Template is in rest/base.html
copy it from djangocms_rest_view/client/templates/rest/base.html
and edit it according your needs.
Each django CMS has a defined template to render.
You can customize the template the AngularJS client will use to render the page:
- create a
partial
directory in thestatic
directory - create
html
files for each page template define the content of the rest-page template to render the placeholders and page title:
<article class="body"> <h2 ng-bind="content_page.title"></h2> <p ng-bind-html="content_page.placeholders.content | safe"></p> </article>
content_page
is the page serialization in the angular scope and contains the full serialization as visible athttp://example.com/api/pages/<page-id>
; thuscontent_page.placeholders.content
contains the rendered HTML for thecontent
placeholder.
Tools used in rendering this package: