簡體   English   中英

在Django 2.1.5和MongoDB 4中使用djongo的問題

[英]Problem using djongo for django 2.1.5 and mongodb 4

我遵循了安裝mongodb和django的教程。 我還使用pip安裝了djongo,並更新了我的項目中的settings.py文件。 但是,當我運行python manage.py runserver時,我發現沒有經過用戶身份驗證的錯誤。我需要在短時間內使它工作,以便有人幫助我。 我錯過了什么?

    Performing system checks...

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fc412ba6400>
Traceback (most recent call last):
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
    self.check_migrations()
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/django/core/management/base.py", line 442, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
    self.build_graph()
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/django/db/migrations/loader.py", line 212, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 61, in applied_migrations
    if self.has_table():
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 44, in has_table
    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/django/db/backends/base/introspection.py", line 56, in table_names
    return get_names(cursor)
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/django/db/backends/base/introspection.py", line 51, in get_names
    return sorted(ti.name for ti in self.get_table_list(cursor)
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/djongo/introspection.py", line 46, in get_table_list
    for c in cursor.db_conn.collection_names(False)
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/pymongo/database.py", line 715, in collection_names
    nameOnly=True, **kws)]
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/pymongo/database.py", line 677, in list_collections
    **kwargs)
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/pymongo/database.py", line 631, in _list_collections
    session=tmp_session)["cursor"]
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/pymongo/database.py", line 514, in _command
    client=self.__client)
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/pymongo/pool.py", line 579, in command
    unacknowledged=unacknowledged)
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/pymongo/network.py", line 150, in command
    parse_write_concern_error=parse_write_concern_error)
  File "/home/habib/.local/share/virtualenvs/habib-HN5dLoHi/lib/python3.6/site-packages/pymongo/helpers.py", line 155, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: there are no users authenticated

我在網上搜索了幾個小時,但仍然無法解決問題。 我注意到我另一台PC上的mongodb是3.4版,它曾經與django一起很好地用作djongo的連接器。 因此,我將mongodb降級為3.4,並清除了所有4.0版本。 這解決了djongo問題。 我猜想它在mongodb 4.0中不能很好地工作。

$ sudo apt purge mongodb-org*
$ sudo apt autoremove
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
$ echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | $ $ sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
$ sudo apt update
$ sudo apt install mongodb-org

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM