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

Typo fixes and style formatting for docstrings #100

Merged
merged 1 commit into from
Jan 17, 2022
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
34 changes: 17 additions & 17 deletions djangochannelsrestframework/observer/base_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,20 @@ async def subscribe_to_comment_activity(self, **kwargs):
.. note::

New feature! This can be rewriting as
.. code-block:: python

...

.. code-block:: python

class MyConsumer(GenericAsyncAPIConsumer):
queryset = User.objects.all()
serializer_class = UserSerializer
class MyConsumer(GenericAsyncAPIConsumer):
queryset = User.objects.all()
serializer_class = UserSerializer

@model_observer(Comments, serializer_class=CommentSerializer)
async def comment_activity(self, message, action, **kwargs):
await self.reply(data=message, action=action)
@model_observer(Comments, serializer_class=CommentSerializer)
async def comment_activity(self, message, action, **kwargs):
await self.reply(data=message, action=action)

@action()
async def subscribe_to_comment_activity(self, **kwargs):
await self.comment_activity.subscribe()
@action()
async def subscribe_to_comment_activity(self, **kwargs):
await self.comment_activity.subscribe()



Expand All @@ -158,14 +157,15 @@ async def subscribe_to_comment_activity(self, **kwargs):
In the IPython shell we will create some comments for differnt users and in the browser console we will se the log.

.. note::

At this point we should have some users in our database, otherwise create them

>>> from my_app.models import User, Comment
>>> user_1 = User.objects.get(pk=1)
>>> user_2 = User.objects.get(pk=2)
>>> Comment.objects.create(text="user 1 creates a new comment", user=user_1)
>>> from my_app.models import User, Comment
>>> user_1 = User.objects.get(pk=1)
>>> user_2 = User.objects.get(pk=2)
>>> Comment.objects.create(text="user 1 creates a new comment", user=user_1)

In the consol log we will se something like this:
In the console log we will see something like this:

.. code-block:: json

Expand Down