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

Readme example of bindings within celery tasks example, Support for channels v1.x #43

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
24 changes: 23 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ channels. It provides a ``ResourceBinding`` which is comparable to Django
Rest Framework's ``ModelViewSet``. It is based on DRF serializer
classes.

It requires Python 2.7 or 3.x, Channels >0.17.3, Django >1.8, and Django Rest Framework 3.0
It requires Python 2.7 or 3.x, Channels 1.x > 0.17.3 , Django >1.8, and Django Rest Framework 3.0

You can learn more about channels-api from my talk at the `SF Django Meetup <https://vimeo.com/194110172#t=3033>`__ or `PyBay 2016 <https://www.youtube.com/watch?v=HzC_pUhoW0I>`__

Expand Down Expand Up @@ -156,6 +156,28 @@ That's it. You can now make REST WebSocket requests to the server.
}
}

- Bindings within asyncronous tasks using celery (Optional)

To ensure bindings are properly connected to model instances used
within celery tasks, create a celery function to initialize the bindings
on celeryd_init.connect

.. code:: Python

# polls/tasks.py
from celery.signals import celeryd_init

@celeryd_init.connect
def register_model_bindings(**kwargs):
binding = QuestionBinding
model = binding.model

pre_save.connect(binding.pre_save_receiver, sender=model)
post_save.connect(binding.post_save_receiver, sender=model)
pre_delete.connect(binding.pre_delete_receiver, sender=model)
post_delete.connect(binding.post_delete_receiver, sender=model)


- Add the channels debugger page (Optional)

This page is helpful to debug API requests from the browser and see the
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
django
djangorestframework
-e [email protected]:django/channels.git#egg=channels
-e [email protected]:django/channels.git@1.x#egg=channels