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
Update docs for better clarity
  • Loading branch information
fsbraun committed Jun 25, 2024
commit 5794f186141fdaf242eef7874fab2b38746e90a2
3 changes: 3 additions & 0 deletions cms/models/contentmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ def get_placeholder_slots(self):
break
else: # No matching placeholder list found
self._placeholder_slot_cache = get_cms_setting('PLACEHOLDERS')[0][1]
if isinstance(self._placeholder_slot_cache, str):
# Accidentally a strong not a tuple? Make it a 1-element tuple
self._placeholder_slot_cache = (self._placeholder_slot_cache,)
return self._placeholder_slot_cache

def get_template(self):
Expand Down
3 changes: 2 additions & 1 deletion cms/utils/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ def check_template_conf(output):
if not isinstance(placeholder, (list, tuple)):
section.error("CMS_PLACEHOLDERS setting contains a non-list/tuple entry")
elif not isinstance(placeholder[0], str):
section.error("CMS_PLACEHOLDERS contains a non-string entry")
section.error(f"CMS_PLACEHOLDERS contains an entry with a non-string identifier: "
f"{placeholder[0]}")
else:
section.success("CMS_PLACEHOLDERS setting entry found - CMS will run in headless mode")
else:
Expand Down
38 changes: 28 additions & 10 deletions docs/how_to/21-headless.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,29 +86,47 @@ 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
``settings.py`` file (or remove it entirely):
First, set the :setting:`CMS_TEMPLATES` setting to an empty list in your
project's ``settings.py`` file (or remove it entirely):

.. code-block:: python

CMS_TEMPLATES = []

Then, you can define the placeholders using the ``CMS_PLACEHOLDERS`` setting:
Then, you can define the placeholders using the :setting:`CMS_PLACEHOLDERS`
setting:

.. code-block:: python

CMS_PLACEHOLDERS = (
('single', ('content'), _('Single placeholder')),
('single', ('content',), _('Single placeholder')),
('two_column', ('left', 'right'), _('Two columns')),
)

The ``CMS_PLACEHOLDERS`` setting is a list of tuples. Each tuple represents a
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.
The 8181 :setting:`CMS_PLACEHOLDERS` setting is a list of tuples. Each tuple
represents a placeholder configuration. Think of each placeholder configuration
replacing a template and providing the information on which placeholders
are available on a page: Like a template can have multiple ``{% placeholder %}``
template tags, a placeholder configuration can contain multiple placeholders.

The first element of the configuration tuple is the name of the placeholder
configuration. It is stored in a page's ``template`` field. It needs to be
unique. The second element is a tuple of placeholder slots available for the
configuration. The third element is the verbose description of the placeholder
configuration which will be shown in the toolbar. You can select a page's
placeholder configuration in the Page menu (instead of a template).

.. note::

:setting:`CMS_PLACEHOLDERS` is only relevant, if no templates are used.
If you define templates, placeholders are inferred from the templates.

Also, do not confuse the :setting:`CMS_PLACEHOLDERS` setting with the
:setting:`CMS_PLACEHOLDER_CONF` setting. The latter is used to configure
individual placeholders, while the former is used to define available
placeholders for a page.

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
plugins in a minimally styled template. Note that the ``css`` and ``js`` block
of the plugin templates will be loaded also in this case.
Loading
0