pennlabs / django-rest-live Goto Github PK
View Code? Open in Web Editor NEWSubscribe to updates from Django REST Framework over Websockets.
Home Page: https://django-rest-live.readthedocs.io/
License: MIT License
Subscribe to updates from Django REST Framework over Websockets.
Home Page: https://django-rest-live.readthedocs.io/
License: MIT License
Hi! I just wanna tell you that there is no way to make it work in my enviroment, i just tried a lot of different things:
This is my requirements.txt:
channels-redis==2.4.2
channels==2.2
daphne
django==3.1.4
django-extensions
django-rest-live
psycopg2
djangorestframework-camel-case
I have set up and followed every step and connected via websockets but i dont receive any update in my model. If you can give a little help or at least upload another example to check with mine it would be great!
Thanks a lot for your work with this package.
Regards
Alejandro
I keep getting
>>> TypeError: __call__() missing 1 required positional argument: 'send'
>>> WebSocket DISCONNECT /ws/products/ [127.0.0.1:59261]
Meanwhile, there is no way for me to access the consumer class and be able to specify what should be sent back to clients.
Also, the documentation doesn't give any good example of subscribing, it just provides a JSON object without specifying where the object should be injected or how it should be done, I've scanned through the whole internet, but I couldn't find an example app, how do I fix an error when I can't even get anything.
I get this error, trying to use the plugin with Channels 3.0.4
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behavior is the source of the following dependency conflicts.
django-rest-live 0.4.4 requires channels<3,>=2.0.0, but you have channels 3.0.4 which is incompatible.
Django REST Live is an open source framework developed by Labs to add support for real-time subscriptions over websockets to Django REST Live. This is especially useful for OHQ!
It would be great for more Labs members to understand how REST Live works. The main goal for this task is to learn about the internals of REST Live. Be sure to think about what each function does in REST Live and when they are invoked.
Additionally, try to add some descriptive docstrings to methods in REST Live to make it easier for others to learn how REST Live works. For docstrings, I recommend using Google style docstrings, though any consistent style of docstring is fine.
This subscription
{
id: new Date().getTime(),
type: "subscribe",
model: "app.MyModel",
action: "retrieve",
lookup_by: 1,
}
returns changes made to any instance of MyModel
.
I stepped through the code.
django-rest-live/rest_live/consumers.py
Line 131 in 52047b6
does indeed return the correct object.
It seems to me that the issue is here:
django-rest-live/rest_live/consumers.py
Line 231 in 52047b6
This should make sure that instance_pk == subscription.view_kwargs['pk']
or similar (ie the instance that triggered the event is the same instance that is subscribed to).
Some backgound: I was trying to figure out why my view's queryset doesn't get filtered by user.
I found out that after this line:
django-rest-live/rest_live/consumers.py
Line 116 in 572689f
base_request._user = scope.get("user", None)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.