Hi ! MySQL and SQLite3 seem to have different behaviour here :
when I have {% if collections %} in a template, where collections is a queryset, using SQlite3 gives this exception : "Caught DatabaseError while rendering: no such function: IF"... No pb with MySQL... Any idea please ? Thanks ;) Yomguy
collections is a queryset coming from urls.py:all_collections = { 'queryset': MediaCollection.objects.enriched(), }
MySQL and SQLite3 seem to have different behaviour here :
when I have {% if collections %} in a template, where collections is a queryset,
using SQlite3 gives this exception :
"Caught DatabaseError while rendering: no such function: IF"...
No pb with MySQL... Any idea please ?
Thanks ;)
YomGuy
I do LOVE Django :)
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')
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