Skip to main content

Easily upload your word documents to Wagtail as pages

Project description

wagtail_word

A Wagtail module to display Word documents in the frontend. Converts your word documents to richtext for easy editing in the Wagtail admin.

Currently supported filetypes:

  • .docx
  • .doc

Currently supported content:

  • Text (Bold, underlines, italic, strikethrough)
    • Text suports colors with allow_styling=True
    • Colors get reset after saving the page in Wagtail admin for a second time.
  • Images
  • Tables
  • Hyperlinks
  • Lists
    • All will be converted to bullet points
    • Single level lists only

Quick start

  1. Add 'wagtail_word' to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
    ...,
    'wagtail_word',
    ]
    
  2. Simply go to your Wagtail Admin.

  3. Create a new Word Page.

  4. Upload a file in the File field.

  5. Save or publish the page and see the magic!

Base Class

We provide a base class to extend from. This class will provide you a predefined FieldPanel for the File, has the allow_styling attribute and a custom method to set the content to the right field for you to override.

# Example class
class WordDocumentPage(BaseWordDocumentPage):
    template = 'wagtail_word/page.html'

    content = RichTextField(
        blank=True,
        null=True,
        features=[
            # Minimal required features for richtext
            "h1", "h2", "h3", "h4", "h5", "h6", 
            "bold", "italic", "ol", "ul", "link" "image", "embed", 
            "blockquote",
        ]
    )

    edit_panels = [
        FieldPanel('content'),
    ]

    edit_handler = TabbedInterface([
        ObjectList(BaseWordDocumentPage.content_panels, heading=_('Upload')),
        ObjectList(edit_panels, heading=_('Edit')),
        ...
    ])
    
    # Override this method to set the content to the right field
    def set_content(self, content: str):
        self.content = content

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

wagtail_word-1.0.6.tar.gz (18.3 kB view details)

Uploaded Source

File details

Details for the file wagtail_word-1.0.6.tar.gz.

File metadata

  • Download URL: wagtail_word-1.0.6.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for wagtail_word-1.0.6.tar.gz
Algorithm Hash digest
SHA256 c0b8dffeb9bb0103fcd7e9c2a7b918e0b360a38a91cf650ed7f92802b9ee3e9a
MD5 0c86505f546153d35ca7d38bf42d3780
BLAKE2b-256 d9bb84c380925bc3f4f85a905daab748e2a37b2b4811131abab0e3cafbc498cc

See more details on using hashes here.

Provenance

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