I've been researching a lot, but I haven't found a way.
I have Document
clases with a _owner
attribute which specifies the ObjectID
of the owner, which is a per-request value, so it's globally available. I would like to be able to set part of the query by default.
For example, doing this query
MyClass.objects(id='12345')
should be the same as doing
MyClass.objects(id='12345', _owner=global.owner)
because _owner=global.owner
is always added by default
I haven't found a way to override objects
, and using a queryset_class
is someway confusing because I still have to remember to call a ".owned()
" manager to add the filter every time I want to query something.
It ends up like this...
MyClass.objects(id='12345').owned()
// same that ...
MyClass.objects(id='12345', _owner=global.owner)
Any Idea? Thanks!