Error in AsyncConsumer in Django channels - django

I used a tutorial for creating a video chat app. But when i run the code it gives me error and it's not so clear to know what is exactly making the problem.
Error:
WebSocket CONNECT /ws/videochat/ [127.0.0.1:38466]
Exception inside application: You cannot call this from an async context - use a thread or sync_to_async.
Traceback (most recent call last):
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 172, in __get__
rel_obj = self.field.get_cached_value(instance)
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/django/db/models/fields/mixins.py", line 13, in get_cached_value
return instance._state.fields_cache[cache_name]
KeyError: 'callee'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/channels/sessions.py", line 183, in __call__
return await self.inner(receive, self.send)
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/channels/sessions.py", line 183, in __call__
return await self.inner(receive, self.send)
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/channels/middleware.py", line 41, in coroutine_call
await inner_instance(receive, send)
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/channels/consumer.py", line 59, in __call__
[receive, self.channel_receive], self.dispatch
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/channels/utils.py", line 51, in await_many_dispatch
await dispatch(result)
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/channels/consumer.py", line 73, in dispatch
await handler(message)
File "/home/nimda/Desktop/videotest/vcp/chat/consumers.py", line 156, in websocket_receive
f"videochat_{videothread.callee.id}",
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 186, in __get__
rel_obj = self.get_object(instance)
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 153, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/django/db/models/query.py", line 411, in get
num = len(clone)
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/django/db/models/query.py", line 258, in __len__
self._fetch_all()
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/django/db/models/query.py", line 1261, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/django/db/models/query.py", line 57, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1149, in execute_sql
cursor = self.connection.cursor()
File "/home/nimda/Desktop/videotest/test/lib/python3.6/site-packages/django/utils/asyncio.py", line 24, in inner
raise SynchronousOnlyOperation(message)
django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.
WebSocket DISCONNECT /ws/videochat/ [127.0.0.1:38392]
consumer.py
The codes are in a pastebin because here gives error for a lot of code:
Show code
How can I solve this? and I should say that the tutorial was okay and that coder made it run.

Related

testdriven.io: The Definitive Guide to Celery and Django. Running task from Django shell causes error

I am currently going through 'The Definitive Guide to Celery and Django' course by testdriven.io. I've managed to containerize the whole application. Everything was built correctly and seemed to work just fine, but when I tried to enter the Django shell and run a task, to ensure everything works correctly, the following error appeared.
>>> divide.delay(1, 2)
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 30, in __call__
return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 446, in _reraise_as_library_errors
yield
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 433, in _ensure_connection
return retry_over_time(
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 312, in retry_over_time
return fun(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 877, in _connection_factory
self._connection = self._establish_connection()
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 812, in _establish_connection
conn = self.transport.establish_connection()
File "/usr/local/lib/python3.10/site-packages/kombu/transport/pyamqp.py", line 201, in establish_connection
conn.connect()
File "/usr/local/lib/python3.10/site-packages/amqp/connection.py", line 323, in connect
self.transport.connect()
File "/usr/local/lib/python3.10/site-packages/amqp/transport.py", line 129, in connect
self._connect(self.host, self.port, self.connect_timeout)
File "/usr/local/lib/python3.10/site-packages/amqp/transport.py", line 184, in _connect
self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 425, in delay
return self.apply_async(args, kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 575, in apply_async
return app.send_task(
File "/usr/local/lib/python3.10/site-packages/celery/app/base.py", line 788, in send_task
amqp.send_task_message(P, name, message, **options)
File "/usr/local/lib/python3.10/site-packages/celery/app/amqp.py", line 510, in send_task_message
ret = producer.publish(
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 177, in publish
return _publish(
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 523, in _ensured
return fun(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 186, in _publish
channel = self.channel
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 209, in _get_channel
channel = self._channel = channel()
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 32, in __call__
value = self.__value__ = self.__contract__()
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 225, in <lambda>
channel = ChannelPromise(lambda: connection.default_channel)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 895, in default_channel
self._ensure_connection(**conn_opts)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 432, in _ensure_connection
with ctx():
File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 450, in _reraise_as_library_errors
raise ConnectionError(str(exc)) from exc
kombu.exceptions.OperationalError: [Errno 111] Connection refused
I've done a quick research and in most cases it seemed to be a lack of the following lines
from config.celery import app as celery_app
__all__ = ['celery_app']
in the config.__init__.py, but it's clearly not an issue here.
I also double checked whether redis container is up and listening on port 6379.
The only difference between my code and the course code is that I decided to use Poetry package manager instead of requirements.txt file and pip.
At this point I am a little bit confused I'll be thankful for any tip. You can find the whole code below:
https://github.com/Kibraks/django-celery-app

Django jwt channels cannot verify

I use djangorestframework-simplejwt.
I have two Django Projects sharing the same database.
One is django-restframework
One is django-channels
django-restframework login will get JWT
I cannot verify successfully in django-channels
I wrote the test function
restframework verify ok
class Test(APIView):
def get(self, request):
try:
token = UntypedToken(
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.???.Z22plhyGEZW9IBZLzICu2mWTkuMrblYQhvUGoUtpKd0')
print(token, 'token') # output: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.???.Z22plhyGEZW9IBZLzICu2mWTkuMrblYQhvUGoUtpKd0
except (InvalidToken, TokenError):
print('InvalidToken, TokenError')
return Response(status=status.HTTP_200_OK)
channels verify error
#database_sync_to_async
def test_get_user():
try:
token = UntypedToken(
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.???.Z22plhyGEZW9IBZLzICu2mWTkuMrblYQhvUGoUtpKd0')
print(token, 'token')
except (InvalidToken, TokenError) as e:
print('InvalidToken, TokenError', e) # output InvalidToken, TokenError Token is invalid or expired
Can't verify JWT like this?
traceback
Exception inside application: Token is invalid or expired
Traceback (most recent call last):
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/rest_framework_simplejwt/backends.py", line 99, in decode
'verify_signature': verify,
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/jwt/api_jwt.py", line 119, in decode
decoded = self.decode_complete(jwt, key, algorithms, options, **kwargs)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/jwt/api_jwt.py", line 95, in decode_complete
**kwargs,
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/jwt/api_jws.py", line 152, in decode_complete
self._verify_signature(signing_input, header, signature, key, algorithms)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/jwt/api_jws.py", line 239, in _verify_signature
raise InvalidSignatureError("Signature verification failed")
jwt.exceptions.InvalidSignatureError: Signature verification failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/rest_framework_simplejwt/tokens.py", line 43, in __init__
self.payload = token_backend.decode(token, verify=verify)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/rest_framework_simplejwt/backends.py", line 105, in decode
raise TokenBackendError(_('Token is invalid or expired'))
rest_framework_simplejwt.exceptions.TokenBackendError: Token is invalid or expired
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/staticfiles.py", line 44, in __call__
return await self.application(scope, receive, send)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/routing.py", line 71, in __call__
return await application(scope, receive, send)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/sessions.py", line 47, in __call__
return await self.inner(dict(scope, cookies=cookies), receive, send)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/sessions.py", line 263, in __call__
return await self.inner(wrapper.scope, receive, wrapper.send)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/auth.py", line 185, in __call__
return await super().__call__(scope, receive, send)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/middleware.py", line 26, in __call__
return await self.inner(scope, receive, send)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/routing.py", line 160, in __call__
send,
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/consumer.py", line 94, in app
return await consumer(scope, receive, send)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/consumer.py", line 59, in __call__
[receive, self.channel_receive], self.dispatch
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/utils.py", line 51, in await_many_dispatch
await dispatch(result)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/consumer.py", line 73, in dispatch
await handler(message)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/generic/websocket.py", line 173, in websocket_connect
await self.connect()
File "/home/user/Daniel/Python/GitLab/django-signalserver/WebSocket/consumers.py", line 147, in connect
await test_get_user()
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/asgiref/sync.py", line 444, in __call__
ret = await asyncio.wait_for(future, timeout=None)
File "/usr/lib/python3.7/asyncio/tasks.py", line 414, in wait_for
return await fut
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/channels/db.py", line 13, in thread_handler
return super().thread_handler(loop, *args, **kwargs)
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/asgiref/sync.py", line 486, in thread_handler
return func(*args, **kwargs)
File "/home/user/Daniel/Python/GitLab/django-signalserver/WebSocket/consumers.py", line 127, in test_get_user
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.???.Z22plhyGEZW9IBZLzICu2mWTkuMrblYQhvUGoUtpKd0')
File "/home/user/Daniel/Python/GitLab/django-signalserver/venv/lib/python3.7/site-packages/rest_framework_simplejwt/tokens.py", line 45, in __init__
raise TokenError(_('Token is invalid or expired'))
rest_framework_simplejwt.exceptions.TokenError: Token is invalid or expired
Because i don't know how jwt verifies
Now I found that the verification method is SECRET_KEY in settings.py
As long as different projects use the same SECRET_KEY.
There is no problem with JWT authentication.

I connected my Django app to MLabs, what do I do now to be able to migrate my database structure to it?

I successfully connected my Django app on my computer to Mlab using Djongo and the homepage on my localhost:8000 server seems to be displaying correctly. However, when I run 'py manage.py migrate', it gives a long list of errors in the terminal and I am not sure how to properly connect to the Mlabs database and populate it with data from the terminal of my Django app in my local computer. How do I migrate the database information onto my Mlab database? I'm not sure what the error is. I'm a little new to Django and MongoDB.
This is a part of the error I see:
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 51, in execute
self.result = Query(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 783, in __init__
self._query = self.parse()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 868, in parse
raise exe from e
djongo.exceptions.SQLDecodeError:
Keyword: None
Sub SQL: None
FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
Params: ['contenttypes', '0001_initial', datetime.datetime(2020, 7, 29, 21, 36, 46, 283726)]
Version: 1.3.3
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
djongo.database.DatabaseError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle
post_migrate_state = executor.migrate(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 246, in apply_migration
self.record_migration(migration)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 261, in record_migration
self.recorder.record_applied(migration.app_label, migration.name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\recorder.py", line 86, in record_applied
self.migration_qs.create(app=app, name=name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 433, in create
obj.save(force_insert=True, using=self.db)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
745, in save
self.save_base(using=using, force_insert=force_insert,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
782, in save_base
updated = self._save_table(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
887, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
924, in _do_insert
return manager._insert(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 1204, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\sql\compiler.py", line 1391, in execute_sql
PS D:\Business\Daydoa\v6-Django_with_MongoDB3\djongo_project> py manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial...This version of djongo does not support "schema validation using CONSTRAINT" fully. Visit https://www.patreon.com/nesdis
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\mongo_client.py", line 1384, in _retry_with_session
return func(session, sock_info, retryable)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 2873, in _find_and_modify
out = self._command(sock_info, cmd,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 235, in _command
return sock_info.command(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\pool.py", line 603, in command
return command(self.sock, dbname, spec, slave_ok,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\network.py", line 165, in command
helpers._check_command_response(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\helpers.py", line 159, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: Transaction numbers are only allowed on storage engines that support document-level locking
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 856, in parse
return handler(self, statement)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 928, in _insert
query.execute()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 374, in execute
auto = self.db['__schema__'].find_one_and_update(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 3134, in find_one_and_update
return self.__find_and_modify(filter, projection,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 2884, in __find_and_modify
return self.__database.client._retryable_write(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\mongo_client.py", line 1491, in _retryable_write
return self._retry_with_session(retryable, func, s, None)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\mongo_client.py", line 1425, in _retry_with_session
raise OperationFailure(errmsg, exc.code, exc.details)
pymongo.errors.OperationFailure: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 51, in execute
self.result = Query(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 783, in __init__
self._query = self.parse()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 868, in parse
raise exe from e
djongo.exceptions.SQLDecodeError:
Keyword: None
Sub SQL: None
FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
Params: ['contenttypes', '0001_initial', datetime.datetime(2020, 7, 29, 21, 37, 1, 197586)]
Version: 1.3.3
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
djongo.database.DatabaseError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle
post_migrate_state = executor.migrate(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 246, in apply_migration
self.record_migration(migration)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 261, in record_migration
self.recorder.record_applied(migration.app_label, migration.name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\recorder.py", line 86, in record_applied
self.migration_qs.create(app=app, name=name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 433, in create
obj.save(force_insert=True, using=self.db)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
745, in save
self.save_base(using=using, force_insert=force_insert,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
782, in save_base
updated = self._save_table(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
887, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
924, in _do_insert
return manager._insert(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 1204, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\sql\compiler.py", line 1391, in execute_sql
cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
django.db.utils.DatabaseError

Django with Google App Engine manage command throws DatabaseError

When I run a management command it opens a browser window.
I authenticate the app which creates a oauth file ~/.googlesql_oauth2.dat.
But it throws a DatabaseError afterwards.
End user Google Account not authorized.enter
Any ideas how to fix this?
Stacktrace:
Unhandled exception in thread started by <bound method Command.inner_run of <django.core.management.commands.runserver.Command object at 0x100646f50>>
Traceback (most recent call last):
File "/usr/local/google_appengine/lib/django_1_3/django/core/management/commands/runserver.py", line 88, in inner_run
self.validate(display_num_errors=True)
File "/usr/local/google_appengine/lib/django_1_3/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/google_appengine/lib/django_1_3/django/core/management/validation.py", line 102, in get_validation_errors
connection.validation.validate_field(e, opts, f)
File "/usr/local/google_appengine/lib/django_1_3/django/db/backends/mysql/validation.py", line 14, in validate_field
db_version = self.connection.get_server_version()
File "/usr/local/google_appengine/lib/django_1_3/django/db/backends/mysql/base.py", line 338, in get_server_version
self.cursor()
File "/usr/local/google_appengine/lib/django_1_3/django/db/backends/__init__.py", line 250, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/usr/local/google_appengine/google/storage/speckle/python/django/backend/base.py", line 223, in _cursor
self.connection = Connect(**kwargs)
File "/usr/local/google_appengine/google/storage/speckle/python/django/backend/base.py", line 195, in Connect
return driver.connect(**kwargs)
File "/usr/local/google_appengine/google/storage/speckle/python/api/rdbms_googleapi.py", line 183, in __init__
super(GoogleApiConnection, self).__init__(*args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/storage/speckle/python/api/rdbms.py", line 583, in __init__
self.OpenConnection()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/storage/speckle/python/api/rdbms.py", line 606, in OpenConnection
response = self.MakeRequest('OpenConnection', request)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/storage/speckle/python/api/rdbms.py", line 718, in MakeRequest
response.sql_exception.message))
google.storage.speckle.python.api.rdbms.DatabaseError: 0: End user Google Account not authorized.enter
All right, I was logged in as a different user when authorizing -.-

Django-Celery 2.5.3 BROKER_URL Error 'No such transport: mysql'

i upgraded my celery from 2.4.X to celery-2.5.2, then modified the Broker_URL to be
BROKER_TRANSPORT = "sqlalchemy"
BROKER_URL = "sqla+mysql://root:root#localhost:3306/db"
this config can be referred via the page of http://docs.celeryproject.org/en/latest/getting-started/brokers/sqlalchemy.html#broker-sqlalchemy
the Celery process can be started successfully, but whan i call .delay or apply_async the process will throw out exception KeyError: 'No such transport: mysql'
i have no idea about this.. looks like everything should be right.
Traceback
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python27\lib\site-packages\celery-2.5.2-py2.7.egg\celery\app\task\__init__.py", line 353, in delay
return self.apply_async(args, kwargs)
File "C:\Python27\lib\site-packages\celery-2.5.2-py2.7.egg\celery\app\task\__init__.py", line 449, in apply_async
publish = publisher or self.app.amqp.publisher_pool.acquire(block=True)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 625, in acquire
R = self.prepare(R)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\pools.py", line 55, in prepare
p = p()
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\pools.py", line 46, in <lambda>
return lambda: self.create_producer()
File "C:\Python27\lib\site-packages\celery-2.5.2-py2.7.egg\celery\app\amqp.py", line 265, in create_producer
pub = self.app.amqp.TaskPublisher(conn, auto_declare=False)
File "C:\Python27\lib\site-packages\celery-2.5.2-py2.7.egg\celery\app\amqp.py", line 328, in TaskPublisher
return TaskPublisher(*args, **self.app.merge(defaults, kwargs))
File "C:\Python27\lib\site-packages\celery-2.5.2-py2.7.egg\celery\app\amqp.py", line 158, in __init__
super(TaskPublisher, self).__init__(*args, **kwargs)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\compat.py", line 61, in __init__
super(Publisher, self).__init__(connection, self.exchange, **kwargs)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\messaging.py", line 69, in __init__
channel = channel.default_channel
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 556, in default_channel
self.connection
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 549, in connection
self._connection = self._establish_connection()
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 509, in _establish_connection
conn = self.transport.establish_connection()
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 569, in transport
self._transport = self.create_transport()
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 324, in create_transport
return self.get_transport_cls()(client=self)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\connection.py", line 331, in get_transport_cls
transport_cls = get_transport_cls(transport_cls)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\transport__init__.py", line 94, in get_transport_cls
_transport_cache[transport] = _get_transport_cls(transport)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\transport\__init__.py", line 75, in _get_transport_cls
transport_module_name, transport_cls_name = resolve_transport(transport)
File "C:\Python27\lib\site-packages\kombu-2.1.5-py2.7.egg\kombu\transport\__init__.py", line 70, in resolve_transport
raise KeyError("No such transport: %s" % (transport, ))
KeyError: 'No such transport: mysql'
After some debugging I've tracked this down to the version of kombu being installed. Kombu 2.1.5 was released on April 13th and does not appear to be compatible. I was able to resolve this issue by explicitly degrading to version 2.1.3.