Python APIs for creating CMS contents. This is done in cms.api and not on the models and managers, because the direct API via models and managers is slightly counterintuitive for developers. Also the functions defined in this module do sanity checks on arguments.
Warning
None of the functions in this modules do any security or permission checks. They verify their input values to be sane wherever possible, however permission checks should be implemented manually before calling any of these functions.
Used for the limit_menu_visibility keyword argument to create_page(). Does not limit menu visibility.
Used for the limit_menu_visibility keyword argument to create_page(). Limits menu visibility to authenticated users.
Used for the limit_menu_visibility keyword argument to create_page(). Limits menu visibility to staff users.
Creates a cms.models.pagemodel.Page instance and returns it. Also creates a cms.models.titlemodel.Title instance for the specified language.
Parameters: |
|
---|
Creates a cms.models.titlemodel.Title instance and returns it.
Parameters: |
|
---|
Adds a plugin to a placeholder and returns it.
Parameters: |
|
---|
Creates a page user for the user provided and returns that page user.
Parameters: |
|
---|
Assigns a user to a page and gives them some permissions. Returns the cms.models.permissionmodels.PagePermission object that gets created.
Parameters: |
|
---|
Publishes a page and optionally approves that publication.
Parameters: |
|
---|
Approves a page.
Parameters: |
|
---|
Create a page called 'My Page using the template 'my_template.html' and add a text plugin with the content 'hello world'. This is done in English:
from cms.api import create_page, add_plugin
page = create_page('My Page', 'my_template.html', 'en')
placeholder = page.placeholders.get(slot='body')
add_plugin(placeholder, 'TextPlugin', 'en', body='hello world')
Inherits django.contrib.admin.options.ModelAdmin.
Defaults to True, if False no preview is done in the admin.
Custom template to use to render the form to edit this plugin.
Custom form class to be used to edit this plugin.
Is the CMSPlugin model we created earlier. If you don’t need model because you just want to display some template logic, use CMSPlugin from cms.models as the model instead.
Will be group the plugin in the plugin editor. If module is None, plugin is grouped “Generic” group.
Will be displayed in the plugin editor.
If set to False, this plugin will not be rendered at all.
Will be rendered with the context returned by the render function.
Whether this plugin can be used in text plugins or not.
Returns the alt text for the icon used in text plugins, see icon_src().
Returns the url to the icon to be used for the given instance when that instance is used inside a text plugin.
This method returns the context to be used to render the template specified in render_template.
Parameters: |
|
---|---|
Return type: | dict |