Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix databases docs #2113

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading