Cleaned up ManyToManyValue set_value method. Also tweaked container template tag...
authorStephen Burrows <stephen.r.burrows@gmail.com>
Thu, 28 Oct 2010 18:38:34 +0000 (14:38 -0400)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Thu, 28 Oct 2010 18:38:34 +0000 (14:38 -0400)
models/base.py
templatetags/containers.py

index 6f881a8..0c2c975 100644 (file)
@@ -121,13 +121,11 @@ class ManyToManyValue(AttributeValue):
                return self.content_type.model_class()._default_manager.filter(id__in=self.get_object_id_list())
        
        def set_value(self, value):
-               if value is None:
-                       self.object_ids = ""
-                       return
-               if not isinstance(value, models.query.QuerySet):
-                       raise TypeError("Value must be a QuerySet.")
-               self.content_type = ContentType.objects.get_for_model(value.model)
-               self.object_ids = ','.join([`value` for value in value.values_list('id', flat=True)])
+               # Value is probably a queryset - but allow any iterable.
+               if isinstance(value, models.query.QuerySet):
+                       value = value.values_list('id', flat=True)
+               
+               self.object_ids = ','.join([str(v) for v in value])
        
        value = property(get_value, set_value)
        
index 8bb0c6b..c5fd445 100644 (file)
@@ -43,7 +43,7 @@ class ContainerNode(template.Node):
                        # Otherwise it's a contentlet.
                        try:
                                contentlet = page.contentlets.get(name__exact=self.name)
-                               if '{%' in contentlet.content:
+                               if '{%' in contentlet.content or '{{' in contentlet.content:
                                        try:
                                                content = template.Template(contentlet.content, name=contentlet.name).render(context)
                                        except template.TemplateSyntaxError, error: