Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Mustache template engine for Django 1.8 and newer, with support for Django context processors.

Project Description

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.


pip3 install django-mustache

Configure django-mustache like you would any template backend:

# myproject/
        '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.

Release History

This version
History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(4.2 kB) Copy SHA256 Hash SHA256
Source None Nov 7, 2016

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate