Skip to content

Commit

Permalink
Add Driver Info into the MongoClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Jibola committed Jan 7, 2025
1 parent ea7e3fc commit 792a59b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion django_mongodb/base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import contextlib
from importlib import metadata

from django.core.exceptions import ImproperlyConfigured
from django.db.backends.base.base import BaseDatabaseWrapper
from pymongo.collection import Collection
from pymongo.driver_info import DriverInfo
from pymongo.mongo_client import MongoClient

from . import dbapi as Database
Expand Down Expand Up @@ -170,7 +172,10 @@ def get_connection_params(self):
}

def get_new_connection(self, conn_params):
return MongoClient(**conn_params)
return MongoClient(**conn_params, driver=self._driver_info())

def _driver_info(self):
return DriverInfo("django-mongodb", metadata.version("django-mongodb"))

def _commit(self):
pass
Expand Down

0 comments on commit 792a59b

Please sign in to comment.