Configuration Error : The DNS query name does not

ConfigurationError at /testapi/

The DNS query name does not exist:

Output with error for extracting db list from mongo db This code works fine when run on a different python file, but I'm getting error when I run with a django project.

from urllib.parse import quote_plus
from pymongo import MongoClient

def auth(username, password, cluster_uri):
username = quote_plus(username)
password = quote_plus(password)
conn_str = "mongodb+srv://{}:{}@{}".format(
return MongoClient(conn_str)

def getDatabaseList(username, password, cluster_address):
client = auth(username, password, cluster_address)
dbs = client.list_database_names()  # returns a list of databases
return dbs

from rest_framework import status
from rest_framework.decorators import permission_classes
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.permissions import AllowAny, IsAuthenticated
from .utils import getDatabaseList

class TestViewSet(APIView):
def post(self, request):
username ='username')
password ='password')
cluster_address ='cluster_address')
dblist = getDatabaseList(username, password, cluster_address)
return Response({'dblist': dblist}, status=status.HTTP_200_OK)

I got the solution Instead of using'name') using request.POST['name'] worked flawle

Back to Top