1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from django import template
register = template.Library()
@register.tag(name='eval')
def do_eval(parser, token):
"Usage: {% eval %}1 + 1{% endeval %}"
nodelist = parser.parse(('endeval',))
class EvalNode(template.Node):
def render(self, context):
return eval(nodelist.render(context))
parser.delete_first_token()
return EvalNode()
|
More like this
- FloatField with safe expression parsing by joelegner 3 years, 2 months ago
- Using the built-in slugify filter outside a template by jcroft 6 years, 2 months ago
- create_update for newforms (ModelForm) by Rozza 5 years, 2 months ago
- create_object and update_object for newforms by danjak 6 years, 2 months ago
- Quiet runserver by danielroseman 2 years, 11 months ago
Comments
Some specialists argue that personal loans aid people to live the way they want, because they are able to feel free to buy needed stuff. Moreover, some banks present auto loan for young and old people.
#