From: Stephen Burrows Date: Wed, 1 Dec 2010 21:49:35 +0000 (-0500) Subject: Corrected embed handling to ignore embedded instances which do not appear in the... X-Git-Tag: philo-0.9~24^2~7 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/ab7d1efef433b723e30a62773f3cf0bbbb35a407?ds=inline;hp=-c Corrected embed handling to ignore embedded instances which do not appear in the context. --- ab7d1efef433b723e30a62773f3cf0bbbb35a407 diff --git a/templatetags/embed.py b/templatetags/embed.py index 901e163..e8c4cae 100644 --- a/templatetags/embed.py +++ b/templatetags/embed.py @@ -65,6 +65,9 @@ def get_embed_dict(embed_list, context): embeds = {} for e in embed_list: ct = e.get_content_type(context) + if ct is None: + # Then the embed doesn't exist for this context. + continue if ct not in embeds: embeds[ct] = [e] else: @@ -263,7 +266,10 @@ class InstanceEmbedNode(EmbedNode): return self.instance.resolve(context) def get_content_type(self, context): - return ContentType.objects.get_for_model(self.get_instance(context)) + instance = self.get_instance(context) + if instance is None: + return None + return ContentType.objects.get_for_model(instance) def get_embedded(self):