From: olivier <> Date: Tue, 22 May 2007 14:25:40 +0000 (+0000) Subject: add method to retrieve items that do not belong to any collection X-Git-Tag: 1.1~918 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=bb5e0f5e2af710915d54caacf2665296d2d5a455;p=telemeta.git add method to retrieve items that do not belong to any collection --- 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"