django_mongoengine.mongo_auth.models中的AttributeError执行Permission.objects.all()

时间:2018-06-19 21:22:16

标签: python-3.6 django-1.11 mongodb-3.6

我正在尝试创建一个添加组的命令。我正在使用MongoDB来存储数据。

我使用 django_mongoengine.mongo_auth 模块(https://github.com/MongoEngine/django-mongoengine

当我尝试执行以下任何一项操作时:

from django_mongoengine.mongo_auth.models import ContentType, Group, Permission

permission = Permission.objects.get(name=permission_name)

permissions = Permission.objects.all()

permission_total = Permissions.object.count()

我收到此错误:

Traceback (most recent call last):
  [...]
  File "./manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "virtualenv\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "virtualenv\lib\site-packages\django\core\management\__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "virtualenv\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "virtualenv\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "app\management\commands\add_groups_tomongo.py", line 119, in handle
    permissions = Permission.objects.all()
  File "virtualenv\lib\site-packages\django\db\models\query.py", line 250, in __iter__
    self._fetch_all()
  File "virtualenv\lib\site-packages\django\db\models\query.py", line 1118, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "virtualenv\lib\site-packages\django\db\models\query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
  File "virtualenv\lib\site-packages\django\db\models\sql\compiler.py", line 871, in execute_sql
    sql, params = self.as_sql()
  File "virtualenv\lib\site-packages\django\db\models\sql\compiler.py", line 423, in as_sql
    extra_select, order_by, group_by = self.pre_sql_setup()
  File "virtualenv\lib\site-packages\django\db\models\sql\compiler.py", line 46, in pre_sql_setup
    self.setup_query()
  File "virtualenv\lib\site-packages\django\db\models\sql\compiler.py", line 36, in setup_query
    self.query.get_initial_alias()
  File "virtualenv\lib\site-packages\django\db\models\sql\query.py", line 892, in get_initial_alias
    alias = self.join(BaseTable(self.get_meta().db_table, None))
  File "virtualenv\lib\site-packages\django\db\models\sql\query.py", line 264, in get_meta
    return self.model._meta
AttributeError: 'NoneType' object has no attribute '_meta'

任何帮助将不胜感激。

谢谢。

0 个答案:

没有答案