oarfish
oarfish

Reputation: 4621

Use Django templates and tags without the rest of Django

I want to use Django for templating, but am not building a web-app. Basically, most of my question has been asked and answered here. But I also need to use a certain tag, which is not a custom tag by me (as addressed in one of the answers), but the mathfilters filters installed with pip. How can I use them in this context?

I read everywhere to rather use something like Jinja for this, but that would be a last resort.

Upvotes: 3

Views: 253

Answers (1)

knbk
knbk

Reputation: 53669

settings.configure() accepts settings as keyword arguments. To activate mathfilters, simply add it to INSTALLED_APP like you would do in settings.py:

import django
from django.conf import settings

settings.configure(INSTALLED_APPS=['mathfilters'])
django.setup()

Then you can use {% load mathfilters %} to load the tags and filters. Note that since Django 1.7 you need to call django.setup() after you've configured your settings.

Upvotes: 2

Related Questions