Skip to main content

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:

https://bitbucket.org/maykinmedia/djangocms-export-page

Keywords:

django cms export docx

PythonVersion:

3.4

build-status Requirements status Coverage status

python-versions django-versions pypi-version

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

img/page-export-menu.png

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

djangocms-export-page-0.1.6.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

djangocms_export_page-0.1.6-py2.py3-none-any.whl (13.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file djangocms-export-page-0.1.6.tar.gz.

File metadata

  • Download URL: djangocms-export-page-0.1.6.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.7

File hashes

Hashes for djangocms-export-page-0.1.6.tar.gz
Algorithm Hash digest
SHA256 4efee44ce5adfe5070209a4e6fdf706ff2f4ae2716be5a767d6979d0f282bd1e
MD5 477933d421751b9b7bd888a83aaa68f3
BLAKE2b-256 2936f165b996da48367edda726b446b1df3416c73a302daf2a4e2f0bbcf69cc7

See more details on using hashes here.

File details

Details for the file djangocms_export_page-0.1.6-py2.py3-none-any.whl.

File metadata

  • Download URL: djangocms_export_page-0.1.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.7

File hashes

Hashes for djangocms_export_page-0.1.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a874bea5ae19436c453c320791b6bece0326cbaf75687fe1ffb770f49e1869bc
MD5 e9d8243f75af26dff2d01a98650ecb8c
BLAKE2b-256 6d73ceb71834438dec1a1a3e0a3a85f2b6a5d0a1ee09858ead1fd8e41639e1e7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page