Skip to main content

DRF View for django CMS

Project description

djangocms-rest-view

Latest PyPI version Monthly downloads Python versions Latest Travis CI build status Test coverage Test coverage Code Climate

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

Installation

  • 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/

Sample client

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/

example:

  • Copy dependencies in project bower.json

  • run bower:

    bower install

Customize

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.

Templates

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 the static 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 at http://example.com/api/pages/<page-id>; thus content_page.placeholders.content contains the rendered HTML for the content placeholder.

Credits

Tools used in rendering this package:

History

0.1.9 (2016-09-25)

  • Fixed compatibility with django CMS 3.4

0.1.8 (2016-09-10)

  • First public “#PyConUK” release

0.1.0 (2016-02-01)

  • Internal release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangocms-rest-view-0.1.9.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

djangocms_rest_view-0.1.9-py2.py3-none-any.whl (18.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file djangocms-rest-view-0.1.9.tar.gz.

File metadata

File hashes

Hashes for djangocms-rest-view-0.1.9.tar.gz
Algorithm Hash digest
SHA256 53b64c1601050b3eba7a34709a0c0b1e6c55c1b594c8aa4492b72d84e873fcbd
MD5 ccae326c3fb041d4a46651f46065ea19
BLAKE2b-256 4d596556ce8d81a48e4480a779edae36e5a88b4c8b66350c70621a138fa2146a

See more details on using hashes here.

File details

Details for the file djangocms_rest_view-0.1.9-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for djangocms_rest_view-0.1.9-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 08088ee987ff2d2816c30611a24ffdbd756bd825861abcc416b11168eed0592b
MD5 49ffe3a388f1e3e61baffa738fb3f2e4
BLAKE2b-256 73e5db9205f03db43a5058fef4faacfed2fda5251eb726d8ddda7b1dd1395fb0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page