Export a Django CMS page or a model view to a DOCX document
Project description
1 Django CMS Export Page
- Version:
0.1.0
- Source:
- Keywords:
django cms export docx
- PythonVersion:
3.4
Export a Django CMS page or a model view to a DOCX document
2 Features
Adds a menu entry in the CMS toolbar to export the current page
Ability to export a custom model, including placeholder fields
3 Installation
3.1 Requirements
Python 3.4 or above
setuptools 30.3.0 or above
Django 1.11 or above
Django CMS 3.4.6 or above
3.2 Install
pip install djangocms-export-page
4 Usage
In your Django settings:
INSTALLED_APPS = [
...
'djangocms_export_page',
...
]
4.1 CMS Page
CMS Page don’t need any extra configuration to work.
If a Plugin has a reverse ForeignKey that would behave like children, add the following to the CMSPlugin model class:
_export_page = {
'children': 'items'
}
@property
def items(self):
return self.frequentlyaskedquestion_set.all()
where items is a iterable attribute of the model class.
And for on the ForeignKey Django model class:
_export_page = {
'fields': ['name', ... ]
}
If you want to export the contents of a ForeignKey or OneToOneField inside the regular model you can use _export_page_field_names. Now these fields will be put in the some level as the plugin fields.
_export_page_field_names = ['number', 'title', 'lead', 'display_date', 'date', 'location']
4.2 Django Model
If you need to export a Django model included in a AppHook, add the following to the model class:
_export_page = {
'sections': [{
'name': 'Meta',
'fields': ['title', ... ]
}, {
'name': 'Body',
'fields': ['content']
}],
}
It’s better to put the PlaceholderField (here content) in a separate section.
4.3 Static Placeholders
If you also want to export the static placeholders of a page, some extra configuration is required. There is a setting called EXPORT_STATIC_PLACEHOLDERS.
EXPORT_STATIC_PLACEHOLDERS = {
'template_name': ['static_placeholder_code']
}
So with the cms settings it will look like this:
# test.html
<div>
{% static_placeholder 'test-placeholder' %}
</div>
# settings.py
CMS_TEMPLATES = [
('test.html', _('Test page')),
]
EXPORT_STATIC_PLACEHOLDERS = {
'test.html': ['test-placeholder']
}
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
Built Distribution
Hashes for djangocms-export-page-0.1.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae07763ce3a1ed0ed2d9fa331d566f03e741b52feda9b0755bf764a28f114fd5 |
|
MD5 | b9cc4f1b76a6f30bc344668b43a627eb |
|
BLAKE2b-256 | 457d594cf98b0fcdbb81f62460825b896af9f3e19f75a5c67dde277deef7c8cd |
Hashes for djangocms_export_page-0.1.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a353f369c06f802f2af5b757c4ed38cbd55f9cdb8ef09b4ebca428112f3af44 |
|
MD5 | 737d3924927a56ab3deed06171d2c9d6 |
|
BLAKE2b-256 | 5264b7b05db90ad45b799b21578ef9ac0cbf748eb65c1f383f51d36feeab17c7 |