Merge pull request #1799 from erdenezul/ensure_indexes_fails_on_slave

Ensure indexes fails on slave #1338
This commit is contained in:
erdenezul 2018-05-23 16:09:51 +08:00 committed by GitHub
commit 758971e068
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -14,6 +14,7 @@ dev
- Use new update_one, update_many on document/queryset update #1491
- Use insert_one, insert_many in Document.insert #1491
- Fix reload(fields) affect changed fields #1371
- Fix Read-only access to database fails when trying to create indexes #1338
Changes in 0.15.0
=================

View File

@ -195,7 +195,10 @@ class Document(BaseDocument):
# Ensure indexes on the collection unless auto_create_index was
# set to False.
if cls._meta.get('auto_create_index', True):
# Also there is no need to ensure indexes on slave.
db = cls._get_db()
if cls._meta.get('auto_create_index', True) and\
db.client.is_primary:
cls.ensure_indexes()
return cls._collection