Sorry Daniel, you're right ! I thought the exception pointed out the "if" statement in the template, but it is in fact the "IF" command in my MediaCollectionQuerySet.
Here is a part of the MediaCollectionManager with its "enriched" method: class MediaCollectionManager(CoreManager): "Manage collection queries" def get_query_set(self): "Return the collection query" return MediaCollectionQuerySet(self.model) def enriched(self): "Query set with additional virtual fields such as apparent_collector" return self.get_query_set().virtual('apparent_collector') And the MediaCollectionQuerySet with its "virtual" method: class MediaCollectionQuerySet(CoreQuerySet): def virtual(self, *args): qs = self for f in args: if f == 'apparent_collector': qs = qs.extra(select={f: 'IF(media_collections.collector_is_creator, ' 'media_collections.creator, media_collections.collector)'}) else: raise Exception("Unsupported virtual field: %s" % f) return qs See for more details: http://telemeta.org/browser/telemeta/models/query.py#L327 http://telemeta.org/browser/telemeta/models/query.py#L279 Thanks for your help Daniel and others, G -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/jy_GaQJOyU8J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.