Looping all items of page

20 views
Skip to first unread message

Vaibhav

unread,
Apr 5, 2020, 3:27:32 AM4/5/20
to django CMS users
Hello all, Is it possible to iterate through all placeholders and plugin using page object.

I am facing issue where static-place holders are not being recognised properly.

Basically I need to list down all building blocked of page programmatically to output placeholders, and all plugins instances used on that page.

Thanks

Samuel Paccoud

unread,
Apr 5, 2020, 4:48:57 AM4/5/20
to djang...@googlegroups.com
Yes you can!


But be careful, pages exist in draft and published version, plugins exist for each language...

Placeholders have a utility method to get plugins for a language: https://github.com/divio/django-cms/blob/develop/cms/models/placeholdermodel.py#L357


Message has been deleted

Vaibhav

unread,
Apr 11, 2020, 1:18:10 PM4/11/20
to django CMS users
Thanks Sam for your response. Actually I am using following way to iterate pages.

for page in Page.objects.filter(**kwargs):

And using this page object to get placeholders, like:

for placeholders in page.get_placeholders():

And further this placeholder object to get plugin list, like:

for plugin in placeholders.get_plugin_list()

But while liating, it's only able to output one of static placeholder however pages contains more then one static place holders.

Please suggest if I am missing something and there is a better way to generate list of page with all it's details (all plugins used on the page)

Thanks, Vaibhav

Reply all
Reply to author
Forward
0 new messages