-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
[BUG] Creating serializer from instance in async context #70
Comments
DRF does the DB query when you do |
Ok thanks! Will try it |
@lautarodapin did this work for you? |
yes thanks! the easiest way was to decorate a method for serializing the current user @database_sync_to_async
def current_user(self) -> ReturnDict:
return UserSerializer(self.scope["user"], many=False).data |
@hishnash do you have a chat or some other active contact app like I just realized that this isnt a query search xD @chats_messages_handler.groups_for_signal
def chats_messages_handler(self, instance: Message, **kwargs):
# this block of code is called very often *DO NOT make DB QUERIES HERE*
yield f'-chat___________{instance.chat_id}'
@chats_messages_handler.groups_for_consumer
def chats_messages_handler(self, chat: int, **kwargs):
# This is called when you subscribe/unsubscribe
if chat is not None:
yield f'-chat___________{chat}' |
@lautarodapin you can DM me on twitter https://twitter.com/hishnash |
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
When I send the action to the websocket, it should add to a group of users, and send to each one the notification, with the key user that is the user that executes the action. BUT when i want to create the serializer in the async context, it never ends.
LOG
The text was updated successfully, but these errors were encountered: