Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mongoengine/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def cascade_save(self, **kwargs):
def _qs(self):
"""Return the default queryset corresponding to this document."""
if not hasattr(self, "__objects"):
self.__objects = QuerySet(self, self._get_collection())
self.__objects = QuerySet(self.__class__, self._get_collection())
return self.__objects

@property
Expand Down
10 changes: 10 additions & 0 deletions tests/document/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ def test_creation(self):
assert person.name == "Test User"
assert person.age == 30

def test__qs_property_does_not_raise(self):
# ensures no regression of #2500
class MyDocument(Document):
pass

MyDocument.drop_collection()
object = MyDocument()
object._qs().insert([MyDocument()])
assert MyDocument.objects.count() == 1

def test_to_dbref(self):
"""Ensure that you can get a dbref of a document."""
person = self.Person(name="Test User", age=30)
Expand Down