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 (ODT for now).

How to use a specific template backend

In the settings, add:

INSTALLED_APPS = [
    ...
    'template_engines',
]

...

TEMPLATES = [
    {
        'BACKEND': 'template_engines.backends.odt.OdtEngine',
        'DIRS': [
        ],
        'APP_DIRS': True,
    },
    {
        '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',
            ],
        },
    },
]

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

Versions

1.1.0

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.0.1.tar.gz (7.0 kB view details)

Uploaded Source

File details

Details for the file django-template-engines-1.0.1.tar.gz.

File metadata

  • Download URL: django-template-engines-1.0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

File hashes

Hashes for django-template-engines-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4f787ce999811d72f25326a8eccf98f5a8c7d73c99fda72e925c869ff2b5109e
MD5 b9537c664758c43ec8a1208a8f4f8918
BLAKE2b-256 0d13edd1c5930ee9008fb6da778667944208385d68a820c15f358bd208170a68

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