Skip to main content

A Django fitemplate field twith managers to return the rendered or unrendered template.

Project description

https://badge.fury.io/py/django-template-field.png https://travis-ci.org/orcasgit/django-template-field.png?branch=master

A Django template field with a manager to return the rendered template.

Documentation

The full documentation is at https://django-template-field.readthedocs.org.

Quickstart

Install django-template-field:

pip install django-template-field

Then use it in a project:

from django.db import models

from templatefield import fields, managers


class TemplatedText(models.Model):
    value = fields.TemplateTextField()

    # Manger that returns rendered templates.
    objects_rendered = managers.RenderTemplateManager()
    # Django's default manager returns unrendered templates.
    objects_unrendered = models.Manager()

Extra context can be added in settings like so:

TEMPLATE_FIELD_CONTEXT = { ‘template_var’: value }

Context can also be added to querysets like so:

TemplatedText.objects_rendered.with_context({‘template_var2’: value2})

Running Tests

source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install -r requirements-test.txt (myenv) $ python runtests.py

History

0.2.0 (2015-10-23)

  • Add with_context to RenderTemplateManager

0.1.0 (2015-10-02)

  • First release on PyPI.

Project details


Download files

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

Source Distribution

django-template-field-0.2.0.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

django_template_field-0.2.0-py2.py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page