Minor corrections to node_url and embed templatetags to avoid raising unnecessary...
authorStephen Burrows <stephen.r.burrows@gmail.com>
Wed, 8 Dec 2010 19:47:13 +0000 (14:47 -0500)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Wed, 8 Dec 2010 19:47:13 +0000 (14:47 -0500)
templatetags/embed.py
templatetags/nodes.py

index e8c4cae..176bbc4 100644 (file)
@@ -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)
 
index 9721ec4..73492d4 100644 (file)
@@ -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:]