register = template.Library()
@register.tag
def test_object(parser, token):
try:
tag, value = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError('%r tag requires a single argument' % token.contents[0])
return TestObject(value)
class TestObject(template.Node):
def __init__(self, value):
self.value = value
def render(self, context):
obj = utils.get_object(context['request'])
context[self.value] = obj
return ''
{% load my_tag %}
{% test_object BigObject %}Caught ImproperlyConfigured while rendering: You haven't set the database ENGINE setting yet
Но мне База Данных и не нужна!! Что делать??? что посоветуете???