Every time my code reaches a certain line it seems to provoke a dictionary update sequence element #0 has length X; 2 is required
error. The value X can change, but the error is almost always provoked when this is called:
if request.user.is_authenticated
It's python 3.6.7
, django 2.1.7
Here is the error stack
Traceback:
File "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
126. response = self.process_exception_by_middleware(e, request)
File "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
124. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "./playerdata/api/tokens.py" in token_queries
87. if request.user.is_authenticated:
File "/path/to/venv/lib/python3.6/site-packages/django/utils/functional.py" in inner
213. self._setup()
File "/path/to/venv/lib/python3.6/site-packages/django/utils/functional.py" in _setup
347. self._wrapped = self._setupfunc()
File "/path/to/venv/lib/python3.6/site-packages/django/contrib/auth/middleware.py" in <lambda>
24. request.user = SimpleLazyObject(lambda: get_user(request))
File "/path/to/venv/lib/python3.6/site-packages/django/contrib/auth/middleware.py" in get_user
12. request._cached_user = auth.get_user(request)
File "/path/to/venv/lib/python3.6/site-packages/django/contrib/auth/__init__.py" in get_user
189. user = backend.get_user(user_id)
File "/path/to/venv/lib/python3.6/site-packages/django/contrib/auth/backends.py" in get_user
98. user = UserModel._default_manager.get(pk=user_id)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/manager.py" in manager_method
82. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/query.py" in get
390. clone = self.filter(*args, **kwargs)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/query.py" in filter
844. return self._filter_or_exclude(False, *args, **kwargs)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/query.py" in _filter_or_exclude
862. clone.query.add_q(Q(*args, **kwargs))
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/sql/query.py" in add_q
1263. clause, _ = self._add_q(q_object, self.used_aliases)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/sql/query.py" in _add_q
1289. joinpromoter.add_votes(needed_inner)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/sql/query.py" in add_votes
2171. self.votes.update(votes)
File "/usr/lib/python3.6/collections/__init__.py" in update
620. super(Counter, self).update(iterable) # fast path when counter is empty
Exception Type: ValueError
Exception Value: dictionary update sequence element #0 has length 9; 2 is required
The code around request.user.is_authenticated:
def token_queries(request):
data = None
if request.user.is_authenticated:
data = login_required(request)
if data is None:
data = anonymous(request)
return json_response(data)
from Django request.user.is_authenticated provokes dictionary update sequence element #0 has length X; 2 is required
No comments:
Post a Comment