File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 8
8
from django .core .exceptions import ImproperlyConfigured
9
9
from django .db .backends .signals import connection_created
10
10
from django .db .utils import DatabaseError
11
+ from pymongo import ReadPreference
11
12
12
13
from pymongo .collection import Collection
13
14
from pymongo .mongo_client import MongoClient
@@ -230,13 +231,16 @@ def pop(name, default=None):
230
231
options [key .lower ()] = options .pop (key )
231
232
232
233
read_preference = options .get ('read_preference' )
234
+ replicaset = options .get ('replicaset' )
235
+
233
236
if not read_preference :
234
237
read_preference = options .get ('slave_okay' , options .get ('slaveok' ))
235
238
if read_preference :
239
+ options ['read_preference' ] = ReadPreference .SECONDARY
236
240
warnings .warn ("slave_okay has been deprecated. "
237
241
"Please use read_preference instead." )
238
242
239
- if read_preference :
243
+ if replicaset :
240
244
connection = MongoReplicaSetClient
241
245
else :
242
246
connection = MongoClient
You can’t perform that action at this time.
0 commit comments