8000 feat: Headless readiness by fsbraun · Pull Request #7850 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

feat: Headless readiness #7850

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 43 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cf26a48
Feat: Move data bridge data to script tags for easier extraction.
fsbraun Mar 21, 2024
600f85a
Fix linting
fsbraun Mar 21, 2024
d0574ed
Move json script before script reading it to avoid race conditions
fsbraun Mar 21, 2024
798829e
lean template
fsbraun Mar 21, 2024
29b7e74
Merge branch 'develop-4' into feat/data-bridge
fsbraun Mar 28, 2024
3c01d6a
Merge branch 'develop-4' into feat/data-bridge
fsbraun Apr 5, 2024
50680e9
Move wizard urls to admin namespace
fsbraun May 7, 2024
73cad7b
Merge branch 'develop-4' into feat/data-bridge
fsbraun May 7, 2024
eaa4edd
Fix linting errors
fsbraun May 7, 2024
c73dc50
Update appresolver and fix page middleware (though no need to use in…
fsbraun May 7, 2024
d733f59
fix: use admin_reverse instead of reverse('admin: ...
fsbraun May 7, 2024
fd2e9be
Update preview condition for toolbar
fsbraun May 8, 2024
6c60e12
Self-contained structure mode css
fsbraun May 8, 2024
23c4d9c
Stay in 4.1.x
fsbraun May 8, 2024
e0edb6f
Merge branch 'develop-4' into feat/data-bridge
fsbraun May 9, 2024
baff66e
Alles structure endpoint for read-only objects
fsbraun May 10, 2024
2872478
fix: linting
fsbraun May 10, 2024
6c65df1
more linting
fsbraun May 10, 2024
851796f
Merge branch 'develop-4' into feat/data-bridge
May 20, 2024
700e537
feat: Allow running without templates
fsbraun May 22, 2024
0cb5fed
Merge branch 'feat/data-bridge' of github.com:fsbraun/django-cms into…
fsbraun May 22, 2024
c50e1a4
Merge branch 'develop-4' into feat/data-bridge
fsbraun May 22, 2024
d5170a4
Add unformatted preview for headless mode
fsbraun May 23, 2024
b73febb
Merge branch 'feat/data-bridge' of github.com:fsbraun/django-cms into…
fsbraun May 23, 2024
3ebffaa
Fix: Advanced placeholder config
fsbraun May 23, 2024
5dbd7ef
Fix: tests
fsbraun May 23, 2024
deff31c
Fix {% render_placeholder %} tag
fsbraun May 23, 2024
46d3da1
Merge branch 'develop-4' into feat/data-bridge
fsbraun May 25, 2024
fc6bee8
Merge branch 'develop-4' into feat/data-bridge
fsbraun May 30, 2024
f35a9d3
Merge branch 'develop-4' into feat/data-bridge
fsbraun Jun 11, 2024
1c61cb7
Add docs
fsbraun Jun 15, 2024
5721225
Merge branch 'feat/data-bridge' of github.com:fsbraun/django-cms into…
fsbraun Jun 15, 2024
cbdae33
Fix typos
fsbraun Jun 15, 2024
f6d8854
Merge branch 'develop-4' into feat/data-bridge
fsbraun Jun 18, 2024
8b5750f
fix typos
fsbraun Jun 22, 2024
5794f18
Update docs for better clarity
fsbraun Jun 25, 2024
91aad91
Merge branch 'develop-4' into feat/data-bridge
fsbraun Jun 25, 2024
ec2219e
Merge branch 'develop-4' into feat/data-bridge
fsbraun Jul 22, 2024
aaf44c0
Merge branch 'develop-4' into feat/data-bridge
fsbraun Jul 25, 2024
583ceb2
Fix: Use user language for headless plugin list
fsbraun Jul 26, 2024
d81c9c3
Fix docs typo
fsbraun Jul 26, 2024
cd025f9
Update docs after review
fsbraun Jul 29, 2024
e2af484
Merge branch 'develop-4' into feat/data-bridge
fsbraun Jul 29, 2024
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
Prev Previous commit
Next Next commit
Fix typos
  • Loading branch information
fsbraun committed Jun 15, 2024
commit cbdae33f171951d104f51c13bcc789068a907315
42 changes: 27 additions & 15 deletions docs/how_to/21-headless.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ Django CMS is headless-ready. This means that you can use django CMS as a
backend service to provide content to the frontend technology of your choice.

Traditionally, django CMS serves the content as HTML pages. In headless mode,
django CMS does not publish the html page tree. To retrieve conten in headless
django CMS does not publish the html page tree. To retrieve content in headless
mode you will need an application that serves the content from the CMS via an
API, such as djangocms-rest. (You can also run a hybrid mode where you serve
**both** the HTML pages and the content via an API, say, for an app. In this
case, just add the API to your traditional project.)
API, such as djangocms-rest.

To run django CMS in headless mode, you simply remove the catch-all URL pattern
from your projects' ``urls.py`` file and replace it by an API endpoint:
Expand All @@ -28,8 +26,15 @@ Now, django CMS will be fully accessible through the admin interface, but the
frontend will not be served. Once, you add an API endpoint, this will be the
only way to access the content.

To add an API endpoint, you can use the `djangocms-rest` package. This package
provides a REST API for django CMS. To install it, run:
.. note::

You can also run a hybrid mode where you serve **both** the HTML pages
and the content via an API, say, for an app. In this case, keep the django CMS' URLS and just add the
API to your traditional project.


To add an API endpoint, you can use the ``djangocms-rest`` package, for example.
This package provides a REST API for django CMS. To install it, run:

.. code-block:: bash

Expand All @@ -48,7 +53,8 @@ Then, add the following to your ``urls.py`` file:
.. note::

Django CMS does not force you to use the ``djangocms-rest`` package. You can
use any other package that provides an API for django CMS.
use any other package that provides an API for django CMS, with
a different API such as GraphQL, for example.

If you are using a different API package, you will need to follow the
instructions provided by that package.
Expand All @@ -65,21 +71,22 @@ Django templates.

If you keep the ``CMS_TEMPLATES`` setting in your project, you still will be
using templates to render the content when editing and previewing in headless
mode.
mode. In this case, the templates will be used to identify the placeholders of
a page.

If ``CMS_TEMPLATES`` is set, the templates will be used to identify the
placeholders of a page.
This scenario requires templates to be present in the project for the benefit
of the editors only.


****************************
Headless without tempaltes
Headless without templates
****************************

However, when running Django CMS headlessly, you can fully decouples the
front-end presentation layer (which includes templates) from the CMS, and the
configuration of placeholders is handled differently.
However, when running Django CMS headlessly without templates, you fully
decouple the front-end presentation layer (which includes templates) from the
CMS, and the configuration of placeholders must be handled differently.

First, set the ``CMS_TEMPLATES`` setting to an empty list in your project's
First, set the ``CMS_TEMPLATES`` setting to an empty list in your project's
``settings.py`` file (or removing it entirely):

.. code-block:: python
Expand All @@ -100,3 +107,8 @@ placeholder configuration. The first element of the tuple is the name of the
placeholder configuration. The second element is a tuple of placeholder names.
The third element is the verbose description of the placeholder configuration
which will be shown in the user interface.

This scenario is useful when you do not want to design templates and focus on
the content structure only. Editors will see a generic representation of the
plugins in a minimally styled template. Note that the ``css`` and ``js``block
of the plugin templates will be loaded also in this case.
1 change: 1 addition & 0 deletions docs/how_to/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Using core functionality
Enable frontend editing for Page and Django models <06-frontend_models>
Create sitemaps <07-sitemaps>
Manage Page Types <08-page_types>
Headless mode <21-headless>

Creating new functionality
--------------------------
Expand Down
Loading
0