I am asking this question here because I believe one or some of my Django settings might be wrong…
Having read through a lot of posts on the following error, I have understood that if you connect to your MongoDB database via pymongo
, you should remove the DATABASES section in your settings.py
file:
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
I have removed it, but I still get this error. Nonetheless, I have tried the suggestions in related posts, to no avail…
In my settings.py
file, I have my database connection:
DB_NAME = 'mongodb+srv://User2021:TestMe@cluster0.j9jz1.mongodb.net/test'
In my views.py
file, I have written a simple method, just to start off:
@csrf_exempt
def consumers(request):
print("consumers")
data = ConsumerModel.objects.all()
if request.method == 'GET':
serializer = ConsumerModelSerializer(data, many=True)
return JsonResponse(serializer.data, safe=False)
When I enter the http://localhost:8000/consumers/
, I just wanna see that the python print statement writes consumers.
What am I missing?