From bb5e0f5e2af710915d54caacf2665296d2d5a455 Mon Sep 17 00:00:00 2001 From: olivier <> Date: Tue, 22 May 2007 14:25:40 +0000 Subject: [PATCH] add method to retrieve items that do not belong to any collection --- telemeta/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/telemeta/models.py b/telemeta/models.py index e59f0930..00f94a1e 100644 --- a/telemeta/models.py +++ b/telemeta/models.py @@ -16,7 +16,7 @@ from django.conf import settings import telemeta from telemeta.core import * from telemeta import dublincore as dc -from xml.dom import getDOMImplementation +from xml.dom.minidom import getDOMImplementation # Regular (sub) expression for matching/validating media objects IDs media_id_regex = r'[0-9A-Za-z._:%?-]+' @@ -205,6 +205,12 @@ class MediaItemManager(models.Manager): Q(_title__icontains=pattern) ) + def without_collection(self): + "Find items which do not belong to any collection" + qs = super(MediaItemManager, self).get_query_set() + return qs.extra( + where = ["collection_id NOT IN (SELECT id FROM telemeta_collection)"]); + class MediaItem(models.Model, MediaCore): "Describe a item with metadata" -- 2.39.5