Skip to content

Commit 082f12d

Browse files
authored
Add Driver Info into the MongoClient (#210)
1 parent ea7e3fc commit 082f12d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

django_mongodb/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import contextlib
2+
import os
23

34
from django.core.exceptions import ImproperlyConfigured
45
from django.db.backends.base.base import BaseDatabaseWrapper
56
from pymongo.collection import Collection
7+
from pymongo.driver_info import DriverInfo
68
from pymongo.mongo_client import MongoClient
79

10+
from . import __version__ as django_mongodb_backend_version
811
from . import dbapi as Database
912
from .client import DatabaseClient
1013
from .creation import DatabaseCreation
@@ -170,7 +173,12 @@ def get_connection_params(self):
170173
}
171174

172175
def get_new_connection(self, conn_params):
173-
return MongoClient(**conn_params)
176+
return MongoClient(**conn_params, driver=self._driver_info())
177+
178+
def _driver_info(self):
179+
if not os.environ.get("RUNNING_DJANGOS_TEST_SUITE"):
180+
return DriverInfo("django-mongodb-backend", django_mongodb_backend_version)
181+
return None
174182

175183
def _commit(self):
176184
pass

0 commit comments

Comments
 (0)