Skip to content

INTPYTHON-424 Prevent redundant requirement for USER and PASSWORD arguments when URI with authentication is provided #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions django_mongodb/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,19 @@ def init_connection_state(self):
super().init_connection_state()

def get_connection_params(self):
settings_dict = self.settings_dict
return {
"host": settings_dict["HOST"] or None,
"port": int(settings_dict["PORT"] or 27017),
"username": settings_dict.get("USER"),
"password": settings_dict.get("PASSWORD"),
**settings_dict["OPTIONS"],
settings_dict = {
"host": self.settings_dict["HOST"] or None,
"port": int(self.settings_dict["PORT"] or None),
**self.settings_dict["OPTIONS"],
}

if username := settings_dict.get("USER"):
settings_dict["username"] = username
if password := settings_dict.get("PASSWORD"):
settings_dict["password"] = password

return settings_dict

def get_new_connection(self, conn_params):
return MongoClient(**conn_params)

Expand Down
Loading