Fix PY3 hasattr connecting to the db at define time
This commit is contained in:
parent
0d0befe23e
commit
14b6c471cf
2 changed files with 3 additions and 1 deletions
|
|
@ -340,7 +340,7 @@ class TopLevelDocumentMetaclass(DocumentMetaclass):
|
|||
new_class._meta['collection'] = collection(new_class)
|
||||
|
||||
# Provide a default queryset unless exists or one has been set
|
||||
if not hasattr(new_class, 'objects'):
|
||||
if 'objects' not in dir(new_class):
|
||||
new_class.objects = QuerySetManager()
|
||||
|
||||
# Validate the fields and set primary key if needed
|
||||
|
|
|
|||
|
|
@ -1857,6 +1857,8 @@ class InstanceTest(unittest.TestCase):
|
|||
def test_db_alias_propagates(self):
|
||||
"""db_alias propagates?
|
||||
"""
|
||||
register_connection('testdb-1', 'mongoenginetest2')
|
||||
|
||||
class A(Document):
|
||||
name = StringField()
|
||||
meta = {"db_alias": "testdb-1", "allow_inheritance": True}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue