X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/46997a51ed0ceb16ddbac712fbcb552a86cdc9e2..1a56dac4a9131e6c453ef496fe8a496969e8ff0d:/philo/templatetags/containers.py diff --git a/philo/templatetags/containers.py b/philo/templatetags/containers.py index 722f2d8..bc04b9f 100644 --- a/philo/templatetags/containers.py +++ b/philo/templatetags/containers.py @@ -1,17 +1,6 @@ """ The container template tags are automatically included as builtins if :mod:`philo` is an installed app. -.. templatetag:: container - -container ---------- - -If a template using this tag is used to render a :class:`.Page`, that :class:`.Page` will have associated content which can be set in the admin interface. If a content type is referenced, then a :class:`.ContentReference` object will be created; otherwise, a :class:`.Contentlet` object will be created. - -Usage:: - - {% container [[references .] as ] %} - """ from django import template @@ -75,9 +64,14 @@ class ContainerNode(template.Node): return content -def do_container(parser, token): +@register.tag +def container(parser, token): """ - {% container [[references .] as ] %} + If a template using this tag is used to render a :class:`.Page`, that :class:`.Page` will have associated content which can be set in the admin interface. If a content type is referenced, then a :class:`.ContentReference` object will be created; otherwise, a :class:`.Contentlet` object will be created. + + Usage:: + + {% container [[references .] as ] %} """ params = token.split_contents() @@ -93,7 +87,7 @@ def do_container(parser, token): if option_token == 'references': try: app_label, model = remaining_tokens.pop(0).strip('"').split('.') - references = ContentType.objects.get(app_label=app_label, model=model) + references = ContentType.objects.get_by_natural_key(app_label, model) except IndexError: raise template.TemplateSyntaxError('"%s" template tag option "references" requires an argument specifying a content type' % tag) except ValueError: @@ -111,6 +105,3 @@ def do_container(parser, token): else: # error raise template.TemplateSyntaxError('"%s" template tag provided without arguments (at least one required)' % tag) - - -register.tag('container', do_container)