django-mako 
The simple, elegant Django Mako library Used base engine to create a template rendering class to be used like Django's TemplateView class. To understand how to use it, read Custom backends on django.
- The current implementation assumes all system templates are Mako Template. Thus, when you start a new template make sure that the template language is Mako not Django.
- If you want to use another template backend like Django Template Backend, just pass
using='Django'in your FBV or addtemplate_engine = 'mako'in your CBV.
Enjoy! This shouldn't be tricky any more.
Installation
To install the package as a requirement in your python environemnt just do
pip install djangomako
Using the library
After installing the package in your python environment, navigate to
your project's settings.py and add the following lines in the
TEMPLATES variable
TEMPLATES = [
# ...
{
'BACKEND': 'djangomako.backends.MakoBackend',
'NAME': 'mako',
'DIRS': [
os.path.join(BASE_DIR, 'templates'),
],
},
# ...
]
- The
BACKENDvalue is from this library. - The
NAMEis simply the template identifier. - In
DIRSyou're gonna include all the directories that have mako templates. - The order matters here, so if you want your project to support only mako, you just need to remove the Django entry from the templates, while if you need mako as a fallback only, then you need to put it under the Django Template entry.
Template Variables
I passed some template variables to the context if the request objects exists:
CSRF_TOKENandCSRF_INPUT${ csrf_input } ## {% csrf_token %} in Django templates. ${ csrf_token } ## {{ csrf_token }} in Django templates.
- To access the request:
${ request }
- To include a static file url:
${ static('image.png') } ## {% static "image.png" %} in Django templates.
- To reverse a url in the template:
${ url('home') } ## {% url 'home' %} in Django templates.
Detailed Examples?
An example of how to use this library in Class-Based view and Function-Based Views is inside niceapp app.
Errors?
To test how this engine handles errors, just run theserver and go to this path /mako.
Detailed Explanation?
You can find a detailed explanation of how I implemented this library in my blog post named Integrating third-party templates' libraries with Django.
License
The MIT License (MIT) Copyright (c) 2017-2019 Ahmed Jazzar me@ahmedjazzar.com
Metadata
Release files for djangomako 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| djangomako-1.3.2.tar.gz | 6.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| djangomako-1.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.4 kB
Release files / djangomako-1.3.2.tar.gz
| Download URL | djangomako-1.3.2.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
123071c30b0f89836412ee968ff5f0b1788cc555961b3d25f1546458cecc2732
|
|
BLAKE2b-256 checksum How to use checksums |
4ddb582ec954da74aeb268b2161c2f1b875e5354d4d4084f00c675a0761bf955
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Release files / djangomako-1.3.2-py3-none-any.whl
| Download URL | djangomako-1.3.2-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a9d544d52eace7171ebf27d94215546862d54e6f6297f86a5579d4b40a1594ef
|
|
BLAKE2b-256 checksum How to use checksums |
e6970c79b368bbacbb4707f78ab6b7e0a1bb1039ef53d4198a4e44a6db6b0902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Security for djangomako 1.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.