Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
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.
using='Django'
in your FBV or add template_engine = 'mako'
in your CBV.Enjoy! This shouldn't be tricky any more.
To install the package as a requirement in your python environemnt just do
pip install djangomako
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'),
],
},
# ...
]
BACKEND
value is from this library.NAME
is simply the template identifier.DIRS
you're gonna include all the directories that have mako
templates.I passed some template variables to the context if the request objects exists:
CSRF_TOKEN
and CSRF_INPUT
${ csrf_input } ## {% csrf_token %} in Django templates.
${ csrf_token } ## {{ csrf_token }} in Django templates.
${ request }
${ static('image.png') } ## {% static "image.png" %} in Django templates.
${ url('home') } ## {% url 'home' %} in Django templates.
An example of how to use this library in Class-Based view and Function-Based Views is inside niceapp app.
To test how this engine handles errors, just run theserver and go to this path /mako.
You can find a detailed explanation of how I implemented this library in my blog post named Integrating third-party templates' libraries with Django.
The MIT License (MIT) Copyright (c) 2017-2019 Ahmed Jazzar me@ahmedjazzar.com
FAQs
The simple, elegant Django Mako library
We found that djangomako demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.