Django always connects to localhost mongodb

前端 未结 2 927
你的背包
你的背包 2021-01-07 09:26

I have followed the guide of db connection config: https://nesdis.github.io/djongo/database-configuration/

However, it always connects to localhost one, not my setti

相关标签:
2条回答
  • 2021-01-07 10:05

    Have you edited your setting in the settings.py file

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'XXXX',
            'USER': 'XXX',
            'PASSWORD': 'XXXX',
            'HOST': 'XXX.XXX.XXX.XXX',
            'PORT': '3306',
            'OPTION': {
                'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
            }
        }
    }
    
    0 讨论(0)
  • 2021-01-07 10:17

    Is seems that somewhere along the way, djongo changed the structure of the database settings. After wasting days trying to find the solution, I came across a page that had the updated structure, Try setting your DATABASE structure to this:

    DATABASES = {
      'default': {  
        'ENGINE':   'djongo',
        'NAME':     'yourmongodb',
        'CLIENT': {
          'host': 'some-host.or.ip',
          'port': 27017,
          'username': 'youruser',
          'password': 'yourdbpass',
          'authSource': 'yourcollection',
        }
      },
    }
    
    0 讨论(0)
提交回复
热议问题