Skip to content

Commit e6d2b38

Browse files
author
Mark Unsworth
committed
support pymongo 2.x
1 parent 122e62b commit e6d2b38

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

django_mongodb_engine/base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def sql_flush(self, style, tables, sequence_list, allow_cascade=False):
7676
if not options.get('capped', False):
7777

7878
# TODO:Not backwards compatible
79-
collection.delete_many({})
79+
collection.remove({})
8080

8181
return []
8282

@@ -253,9 +253,6 @@ def pop(name, default=None):
253253
warnings.warn("slave_okay has been deprecated. "
254254
"Please use read_preference instead.")
255255

256-
257-
258-
259256
conn_options = dict(
260257
host=host,
261258
port=int(port),
@@ -264,8 +261,13 @@ def pop(name, default=None):
264261
)
265262
conn_options.update(options)
266263

264+
if replicaset:
265+
connection_class = MongoReplicaSetClient
266+
else:
267+
connection_class = MongoClient
268+
267269
try:
268-
self.connection = MongoClient(**conn_options)
270+
self.connection = connection_class(**conn_options)
269271
self.database = self.connection[db_name]
270272
except TypeError:
271273
exc_info = sys.exc_info()

0 commit comments

Comments
 (0)