同时连接Mysql、Mongodb

  1. # 在settings.py文件中编辑如下
  2. DATABASES = {
  3. 'default': {
  4. 'ENGINE': 'django.db.backends.mysql',
  5. 'NAME': 'pule_decision',
  6. 'PORT': '3306',
  7. 'HOST': '127.0.0.1',
  8. 'USER': 'root',
  9. 'PASSWORD': 'password',
  10. 'OPTIONS': {
  11. "init_command": "SET foreign_key_checks = 0;",
  12. "charset": "utf8mb4"
  13. },
  14. },
  15. 'mongodb': {
  16. 'ENGINA': None,
  17. }
  18. }
  19. from mongoengine import connect
  20. connect('mongodbname', host='127.0.0.1', port=27017)