
Product
Introducing Socket MCP for Claude Desktop
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
django-string-renderer
Advanced tools
A thin wrapper around the Django templating system to render any string as a template. It provides an easy way to render any user inputted string as a regular django template.
A thin wrapper around the Django templating system to render any string as a template. It provides an easy way to render any user inputted string as a regular django template.
This wrapper uses no models and requires no other settings than a django
engine in the TEMPLATES
setting where the app is used.
This package uses type annotations and mypy
to check those annotations.
This package is only tested against Python >= 3.10 and Django >= 4.2.
In order to use this app in a Django project, the simplest way is to install it from PyPi:
pip install django-string-renderer
In order to modify or test this app you may want to install it from the source code.
Clone the GitHub repository and then run:
pip install -r requirements.txt -r requirements-dev.txt
Start by adding stringrenderer
to your INSTALLED_APPS
setting like this:
INSTALLED_APPS = (
...,
'stringrenderer',
)
Then use the StringTemplateRenderer
class to build a Django template instance from a string et render the string with the context of your choice:
import stringrenderer
template_string = "Hello {{ recipient.first_name }} {{ recipient.last_name }}!"
renderer = StringTemplateRenderer(template_string)
rendered_content = renderer.render_template(context=dict(recipient=recipient_1), request=request)
rendered_content = renderer.render_template(context=dict(recipient=recipient_2), request=None)
When the first rendering request occurs on a given StringTemplateRenderer
instance, a Template
object is built from the string passed to __init__()
, and cached for the next rendering operations with other contexts.
You may check the template syntax of a string like this:
import stringrenderer
template_string = "Hello {{ recipient.first_name }} {{ recipient.last_name }}!"
is_valid, syntax_error = check_template_syntax(template_string)
Get the source code from GitHub, follow the installation instructions above, and run the following commands:
python runtests.py
python -m mypy --ignore-missing-imports stringrenderer/
This will run the test suite with the locally installed version of Python and Django.
This app is used in the following projects:
FAQs
A thin wrapper around the Django templating system to render any string as a template. It provides an easy way to render any user inputted string as a regular django template.
We found that django-string-renderer 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.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.