Skip to main content

django-mustache

A straightforward Mustache-powered template engine for Django, extracted from wq.db and updated to support the new template backend infrastructure in Django 1.8 and newer. django-mustache facilitates progressive enhancement by allowing you to share the same templates between Django and an offline-capable JavaScript web app. Combined with a shared URL structure, this approach ensures that each page in your site can be selectively rendered on the server or on the client as needed.

A number of Pystache/Mustache backends for Django exist, though many are outdated. Only this library provides all of the following:

  • Full integration with existing Django context processors like django.template.context_processors.csrf and django.contrib.auth.context_processors.auth.*
  • Full test suite
  • Installable via PyPI
  • Compatible with Django 1.8 and newer

*wq/app.js provides client-side equivalents for these context variables.

Latest PyPI Release Release Notes License GitHub Stars GitHub Forks GitHub Issues

Travis Build Status Python Support Django Support

Usage

pip3 install django-mustache

Configure django-mustache like you would any template backend:

# myproject/settings.py
TEMPLATES = [
    {
        'BACKEND': 'django_mustache.Mustache',
        'DIRS': [ '...' ],
        'APP_DIRS': False,
        'OPTIONS': {
            'context_processors': [ '...' ],
            'partials_dir': 'partials',
            'file_extension': 'html',
        }
    },
    # ...
]

The following configuration options are supported:

  • context_processors: equivalent to the Django template backend setting. The goal is to be able to use the same context processors for both Django and Mustache template backends. (Let us know if you come across any compatibility issues.)
  • partials_dir: If set, django-mustache will check each template directory for a subfolder containing Mustache partial templates. The default partial folder name is 'partials'. Set to False to disable this feature.
  • file_extension: File extension to use when searching for templates and partials. The default is '.html', which should not conflict with existing Django templates as long as completely separate directories are configured for Mustache templates. Django views typically include the extension in the template name - this is taken into account when searching for templates.

Metadata

Release files for django-mustache 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-mustache 1.1.2
File Size Uploaded
django-mustache-1.1.2.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-mustache 1.1.2
File Interpreter ABI Platform
django_mustache-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.5 kB

Release files / django-mustache-1.1.2.tar.gz

Download URL django-mustache-1.1.2.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
44d29f56e0cf4a52cb12e2e97d5a45fd6f1242eb5d5ae79af4750ab83083a8b4
BLAKE2b-256 checksum
How to use checksums
086907a0c00262321044945b7edbe5482e687399a3fe3ed74797dde4b5115600
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

Release files / django_mustache-1.1.2-py3-none-any.whl

Download URL django_mustache-1.1.2-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
576c42d6f8d12c8953784608b17ec16c810035bf0717d73fa6ef6156d5170813
BLAKE2b-256 checksum
How to use checksums
22db5fcd5499baba12a276fadb3bb29b82d33714a4cea8fca7b8e3abf91bc4d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

1 release file

1.0.0

1 release file

0.1.0

1 release file

0.1.0-dev

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page