每当我过滤管理模块中的组时,都会引发 sql 解码错误。除了与用户模型的一些一对一关系外,我没有对有关用户或组的管理界面或模型进行任何修改。该错误仅在过滤组时引发。
有什么办法可以防止这个错误被引发?
错误如下:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/auth/user/?groups__id__exact=1
Django Version: 2.2.10
Python Version: 3.8.1
Installed Applications:
['game.apps.GameConfig',
'user.apps.UserConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/sql2mongo/query.py" in parse
824. return handler(self, statement)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/sql2mongo/query.py" in _select
963. self._query = SelectQuery(self.db, self.connection_properties, sm, self._params)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/sql2mongo/query.py" in __init__
111. super().__init__(*args)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/sql2mongo/query.py" in __init__
72. self.parse()
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/sql2mongo/query.py" in parse
119. c = self.selected_columns = ColumnSelectConverter(self, tok_id)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/sql2mongo/converters.py" in __init__
44. super().__init__(query_ref, begin_id)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/sql2mongo/converters.py" in __init__
24. self.parse()
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/sql2mongo/converters.py" in parse
63. raise SQLDecodeError
The above exception () was the direct cause of the following exception:
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/contrib/admin/options.py" in wrapper
606. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/contrib/admin/sites.py" in inner
223. return view(request, *args, **kwargs)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/utils/decorators.py" in _wrapper
45. return bound_method(*args, **kwargs)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/contrib/admin/options.py" in changelist_view
1685. cl = self.get_changelist_instance(request)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/contrib/admin/options.py" in get_changelist_instance
731. return ChangeList(
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/contrib/admin/views/main.py" in __init__
82. self.get_results(request)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/contrib/admin/views/main.py" in get_results
210. result_count = paginator.count
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/utils/functional.py" in __get__
80. res = instance.__dict__[self.name] = self.func(instance)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/core/paginator.py" in count
91. return c()
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/db/models/query.py" in count
392. return self.query.get_count(using=self.db)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/db/models/sql/query.py" in get_count
504. number = obj.get_aggregation(using, ['__count'])['__count']
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/db/models/sql/query.py" in get_aggregation
489. result = compiler.execute_sql(SINGLE)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/db/models/sql/compiler.py" in execute_sql
1133. cursor.execute(sql, params)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/db/backends/utils.py" in execute
99. return super().execute(sql, params)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/db/backends/utils.py" in execute
67. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/db/backends/utils.py" in _execute_with_wrappers
76. return executor(sql, params, many, context)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/django/db/backends/utils.py" in _execute
84. return self.cursor.execute(sql, params)
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/cursor.py" in execute
48. self.result = Result(
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/sql2mongo/query.py" in __init__
753. self.parse()
File "/Users/jayjay/anaconda3/envs/djongo/lib/python3.8/site-packages/djongo/sql2mongo/query.py" in parse
846. raise exe from e
Exception Type: SQLDecodeError at /admin/auth/user/
Exception Value: FAILED SQL: SELECT COUNT(*) FROM (SELECT DISTINCT "auth_user"."id" AS Col1, "auth_user"."password" AS Col2, "auth_user"."last_login" AS Col3, "auth_user"."is_superuser" AS Col4, "auth_user"."username" AS Col5, "auth_user"."first_name" AS Col6, "auth_user"."last_name" AS Col7, "auth_user"."email" AS Col8, "auth_user"."is_staff" AS Col9, "auth_user"."is_active" AS Col10, "auth_user"."date_joined" AS Col11 FROM "auth_user" INNER JOIN "auth_user_groups" ON ("auth_user"."id" = "auth_user_groups"."user_id") WHERE "auth_user_groups"."group_id" = %(0)s) subquery
Params: (1,)
Version: 1.3.1
这是 pip freeze 的输出:
certifi==2019.11.28
dataclasses==0.6
Django==2.2.10
django-jsoneditor==0.1.5
djongo==1.3.1
jsonfield==3.1.0
packaging==20.1
pymongo==3.10.1
pyparsing==2.4.6
python-dateutil==2.8.1
pytz==2019.3
six==1.14.0
sqlparse==0.2.4