Comments (6)
DRF does the DB query when you do user_serializer.data
not on its __init__
method... the cleanest way to deal with this is to create a method that creates the UserSerializer
and returns the .data
.
from djangochannelsrestframework.
@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
from djangochannelsrestframework.
DRF does the DB query when you do
user_serializer.data
not on its__init__
method... the cleanest way to deal with this is to create a method that creates theUserSerializer
and returns the.data
.
Ok thanks! Will try it
from djangochannelsrestframework.
@lautarodapin did this work for you?
from djangochannelsrestframework.
@hishnash do you have a chat or some other active contact app like slack
?
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}'
from djangochannelsrestframework.
@lautarodapin you can DM me on twitter https://twitter.com/hishnash
from djangochannelsrestframework.
Related Issues (20)
- [BUG] HOT 1
- Add @observer_ After model, the database route fails and cannot be written HOT 3
- need more documents for groups_for_signal and groups_for_consumer, and what "__" means in the examples HOT 2
- [BUG] TypeError: can not serialize 'UUID' object models with pk type uuid HOT 2
- Question about client notify HOT 1
- support for request build_absolute_uri
- [BUG] It's impossible to fully use a REAL WORLD viewset via view_as_consumer HOT 1
- [BUG] aws(elastickbeanstalk) and library HOT 1
- observer for instances based on foregien key HOT 2
- [BUG] Can't override get_queryset method when using ObserverModelInstanceMixin and GenericAsyncAPIConsumer HOT 3
- [BUG] app() missing 2 required positional arguments: 'receive' and 'send'
- Document support for channels v4 HOT 1
- [BUG] HOT 1
- Add link to ReadTheDocs in GitHub Project Description HOT 1
- `chat/layout.html` referenced in tutorial is missing HOT 7
- Object level permission HOT 4
- [Feature request] Dynamic subscription filtering through query params. HOT 7
- [Feature] support OR operations for group subscriptions
- [Feature] Subscribe to changes of a given field/fields
- djangochannelsrestframework working with gunicorn HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from djangochannelsrestframework.