From: Stephen Burrows Date: Wed, 8 Dec 2010 19:47:13 +0000 (-0500) Subject: Minor corrections to node_url and embed templatetags to avoid raising unnecessary... X-Git-Tag: philo-0.9~24^2~6 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/8025c32db79387a8e57d4222d9489c1e85040c57 Minor corrections to node_url and embed templatetags to avoid raising unnecessary errors. --- diff --git a/templatetags/embed.py b/templatetags/embed.py index e8c4cae..176bbc4 100644 --- a/templatetags/embed.py +++ b/templatetags/embed.py @@ -267,7 +267,7 @@ class InstanceEmbedNode(EmbedNode): def get_content_type(self, context): instance = self.get_instance(context) - if instance is None: + if not instance: return None return ContentType.objects.get_for_model(instance) diff --git a/templatetags/nodes.py b/templatetags/nodes.py index 9721ec4..73492d4 100644 --- a/templatetags/nodes.py +++ b/templatetags/nodes.py @@ -51,7 +51,9 @@ class NodeURLNode(template.Node): subpath = reverse(view_name, urlconf=node.view, args=args, kwargs=kwargs) except NoReverseMatch: if self.as_var is None: - raise + if settings.TEMPLATE_DEBUG: + raise + return settings.TEMPLATE_STRING_IF_INVALID else: if subpath[0] == '/': subpath = subpath[1:]