Skip to main content

Additional template engines for Django.

Project description

Build Status Maintainability codecov Python Version Django Version PyPI version Documentation Status

django-template-engines

Description

Additional template engines for Django.

How to use a specific template backend

In the settings, add:

INSTALLED_APPS = [
    ...
    'template_engines',
]

...

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
    {
        'BACKEND': 'template_engines.backends.odt.OdtEngine',
        ...,
    },
]

A view exemple

from django.views.generic.detail import DetailView


class TemplateView(DetailView):
    queryset = AModel.objects.all()
    template_engine = 'odt'
    content_type = 'application/vnd.oasis.opendocument.text'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['image'] = {'content': open(path, 'rb').read()}
        return context

========= CHANGELOG

1.2.28.dev0 (XXXX-XX-XX)

1.2.27 (2020-04-14)

  • Translate img tag in from_html for odt templates

1.2.26 (2020-05-04)

  • Fix deprecation warnings and bad closing files

1.2.25 (2020-02-24)

  • Fix span tags with text:span in from_html

1.2.24 (2019-12-02)

  • Add rendering of footer and header

1.2.23 (2019-11-29)

  • Remove automatically resize
  • Change value conversion px to odt
  • Add extension at the end of the generated file

1.2.22 (2019-11-25)

  • Change AbstractEngine, inheritate from DjangoTemplates

1.2.21 (2019-11-18)

  • Fix context rendering odt.

1.2.20 (2019-11-15)

  • fix max_height and max_width

1.2.19 (2019-11-14)

  • Add anchor image_url_load, image_load
  • Replace width and height for image_url_load, image_load by max_width and max_height

1.2.18 (2019-11-13)

  • fix odt image inclusion

1.2.17 (2019-11-07)

  • Load odt_tags and docx_tags automatically, remove loads to make it works
  • Add tag image_url_load
  • Fix odt pictures inside zip

1.2.16 (2019-11-04)

  • Allow heading, and text-numbered list in from_html odt tag

1.2.15 (2019-10-28)

  • Fix text-input replacement for list inside paragraphs

1.2.14 (2019-10-25)

  • Fix text-input replacement for odt
  • Add custom style for italic and underline text for html filter

1.2.13 (2019-10-25)

Features:

  • from_html tag filter for odt templates

1.2.12 (2019-10-23)

Fixes:

  • automatic escape break line in odt template

1.2.11 (2019-10-23)

Improve:

  • automatic escape break line in odt template

1.2.10 (2019-10-09)

Improve:

  • Tags are renamed
  • ODT image inclusion

Update:

  • From now on, {% ... %} are also cleaned.

1.2.9 (2019-09-24)

Other:

  • the template is cleaned before it is filled.

1.2.8 (2019-09-24)

Optimize:

  • clean methods

Add:

  • a method that removes incorrect additions in the template tags of the xml file

Update:

  • the documentation

Fix:

  • requirements

Other:

  • AbstractEngine becomes ZipAbstractEngine and allow you to write custom engines for zip base documents

1.2.7 (2019-09-12)

Fixes:

  • template generation from different django storage

1.2.6 (2019-09-12)

Fixes:

  • conditions to determine mimetype template

1.2.5 (2019-09-12)

Fixes:

  • packaging

1.2.4 (2019-09-12)

Fixes:

  • Allow mimetype zip for DOCX and ODT

1.2.3 (2019-09-11)

Fixes:

  • Compatibility with non FileStorageBackend

1.2.2

Update

  • Pillow>=5.4.1

1.2.1

requests is no longer needed.

1.2.0

From now on, you can specify bold text.

1.1.3

Image loaders can now take width and height as dxa, px, pt, in, cm and emu.

1.1.2

Add:

  • A template tag to load images into a docx template (docx_image_loader).

1.0.0

Add:

  • Docx template engine (template_engines.backends.docx.DocxEngine).
  • Docx template class (template_engines.backends.odt.DocxTemplate).

0.0.4

  • Abstract template engine for writing custom engines (template_engines.backends.abstract.AbstractEngine).
  • Abstract template class for writing custom template classes (template_engines.backends.abstract.AbstractTemplate).
  • Odt template engine (template_engines.backends.odt.OdtEngine).
  • Odt template class (template_engines.backends.odt.OdtTemplate).
  • A template tag to load images into an odt template (odt_image_loader).

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

django-template-engines-1.2.28.dev3.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-template-engines-1.2.28.dev3.tar.gz.

File metadata

  • Download URL: django-template-engines-1.2.28.dev3.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for django-template-engines-1.2.28.dev3.tar.gz
Algorithm Hash digest
SHA256 67a7fb1b6d6882fafda19ae8d81fd2f26f984f953b39a95da9c5b8bb3074aacf
MD5 66c6808617e0be259fe63700f18d4cfa
BLAKE2b-256 c038214c5e7f042a842a2b31e3a7dfc8537ca2e67477c82253e11e9561dfc9f4

See more details on using hashes here.

File details

Details for the file django_template_engines-1.2.28.dev3-py3-none-any.whl.

File metadata

  • Download URL: django_template_engines-1.2.28.dev3-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for django_template_engines-1.2.28.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 4d2e1ef0e303d3bd4937a9d7c3848bc35f9c81938166a4a7bb637e48a68e6f4a
MD5 01a38c3dec29975f71c08abf11607824
BLAKE2b-256 ba9c697f2f01a05b9f665e69b0a87ce91745a1515864c0aa2b4e4210c8ee1436

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