From: Stephen Burrows Date: Thu, 28 Oct 2010 18:38:34 +0000 (-0400) Subject: Cleaned up ManyToManyValue set_value method. Also tweaked container template tag... X-Git-Tag: philo-0.9~26^2~12 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/8417d8b404dfe7b0d6e79ecce224584a09ffae94?ds=inline;hp=-c Cleaned up ManyToManyValue set_value method. Also tweaked container template tag to recognize a contentlet as dynamic if it only contains a variable. --- 8417d8b404dfe7b0d6e79ecce224584a09ffae94 diff --git a/models/base.py b/models/base.py index 6f881a8..0c2c975 100644 --- a/models/base.py +++ b/models/base.py @@ -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) diff --git a/templatetags/containers.py b/templatetags/containers.py index 8bb0c6b..c5fd445 100644 --- a/templatetags/containers.py +++ b/templatetags/containers.py @@ -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: