From 3ba76fb328768c77f4f4593f699992543fb50f4a Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Mon, 19 Aug 2024 08:40:54 +0200 Subject: [PATCH] Fix databases docs --- docs/topics/databases.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/topics/databases.rst b/docs/topics/databases.rst index e0d2c4af..ce0be99e 100644 --- a/docs/topics/databases.rst +++ b/docs/topics/databases.rst @@ -47,7 +47,7 @@ call it with ``database_sync_to_async`` like so: from channels.db import database_sync_to_async async def connect(self): - self.username = await database_sync_to_async(self.get_name)() + self.username = await database_sync_to_async(get_name)() def get_name(self): return User.objects.all()[0].name @@ -59,7 +59,7 @@ You can also use it as a decorator: from channels.db import database_sync_to_async async def connect(self): - self.username = await self.get_name() + self.username = await get_name() @database_sync_to_async def get_name(self): @@ -78,4 +78,4 @@ by a channels layer event and needs to make a few ORM queries to determine what to send to the client. This function should be called *before* making those queries. Calling this function more than necessary is not necessarily a bad thing, but it does require a context switch to synchronous code and -so incurs a small penalty. \ No newline at end of file +so incurs a small penalty.