I'm having an hard time editing a database entry from a Django channels consumer, here is the piece of code involved:
class TestConsumer(AsyncJsonWebsocketConsumer):
async def websocket_connect(self, event):
...
key_query.active_connections = 2
key_query.save()
...
Since i'm using an asynchronous consumer, this will give me the following error:
You cannot call this from an async context - use a thread or sync_to_async.
How can i perform this action from an async consumer? Maybe using @database_sync_to_async?Any advice is appreciated!