From b96e27a7e4675c0564cff05bcba66f7662b6099d Mon Sep 17 00:00:00 2001 From: Theo Julienne Date: Fri, 30 Jul 2010 22:09:00 +1000 Subject: [PATCH] Allow documents to override the 'objects' QuerySetManager --- mongoengine/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mongoengine/base.py b/mongoengine/base.py index c8c162b4..ed8214af 100644 --- a/mongoengine/base.py +++ b/mongoengine/base.py @@ -252,7 +252,10 @@ class TopLevelDocumentMetaclass(DocumentMetaclass): # Set up collection manager, needs the class to have fields so use # DocumentMetaclass before instantiating CollectionManager object new_class = super_new(cls, name, bases, attrs) - new_class.objects = QuerySetManager() + + # Provide a default queryset unless one has been manually provided + if not 'objects' in dir(new_class): + new_class.objects = QuerySetManager() user_indexes = [QuerySet._build_index_spec(new_class, spec) for spec in meta['indexes']] + base_indexes