Skip to content

Commit

Permalink
Fix databases docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aminalaee authored Aug 19, 2024
1 parent e533186 commit 3ba76fb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/topics/databases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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.
so incurs a small penalty.

0 comments on commit 3ba76fb

Please sign in to comment.