How to connect Django ORM to mongo atlas?

前端 未结 5 608
情深已故
情深已故 2020-12-21 10:41

I am trying to connect my django instance to a mongo db cluster using django. I have checked from various sources and the way it is getting closer to work is:

5条回答
  •  一个人的身影
    2020-12-21 11:06

    Simplest and correct solution:

    Step 1: Install djongo and dnspython

    pip install djongo

    pip install dnspython

    Step 2: Changes in settings.py:

    DATABASES = {
    "default": {
        "ENGINE": "djongo",
        "CLIENT": {
            "host": "mongodb+srv://:@.mongodb.net/?retryWrites=true&w=majority",
            "username": "",
            "password": "",
            "name": "",
            "authMechanism": "SCRAM-SHA-1",
        },
    }}
    

提交回复
热议问题