So far as our code and the code of another user, we have passed self as the 
first argument in the definition of a function/method.

relating code in consumers.py:
from channels.generic.websocket import AsyncWebsocketConsumer import json 
class Trade(AsyncWebsocketConsumer): 
  async def my_send(self, data): 
    if isinstance(data, dict): 
      d = json.dumps(data) 
    else: 
      d = str(data) 
      await self.send(d) 

Another user's code:
class TestConsumer(WebsocketConsumer): 
  def connect(self): 

在2021年11月30日星期二 UTC+8 23:13:27<ber...@autofyle.com> 写道:

> This kind of error happens when working with classes. When you create 
> methods for a class, you must always pass self as the first argument
> self designates the object in which it is called. You have to pass self as 
> the first argument for each method.
> Does this help ?
>
> On Tuesday, November 30, 2021 at 7:16:11 AM UTC-7 yan.z...@gmail.com 
> wrote:
>
>> Hi there!
>>
>> I have posted this issue like 3 months ago.
>> https://github.com/django/channels/discussions/1736
>>
>> And there are many others encountering similar problem, like this:
>>
>> https://stackoverflow.com/questions/68194577/typeerror-call-missing-1-required-positional-argument-send-django/
>>
>> The similarity is that the codes were running all-right under older 2.x 
>> versions,
>> but encounter the same error on which-ever 3.x versions of 
>> django-channels.
>>
>> Would you please tell us where must be modified to be able to run on 3.x ?
>>
>> Thanks a lot!
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dfe09835-e3ee-4d0c-985c-6b786e5322ean%40googlegroups.com.

Reply via email to