NilCoalescing/djangochannelsrestframework

[BUG] app() missing 2 required positional arguments: 'receive' and 'send'

Closed this issue · 0 comments

App() missing 2 required positional arguments: 'receive' and 'send'

To Reproduce
Steps to reproduce the behavior:

  1. consumers.py

from django.contrib.auth.models import User
from djangochannelsrestframework.consumers import AsyncAPIConsumer
from djangochannelsrestframework.decorators import action
from rest_framework import status

from djangochannelsrestframework.generics import GenericAsyncAPIConsumer
from djangochannelsrestframework.mixins import (
    ListModelMixin,
    RetrieveModelMixin,
    PatchModelMixin,
    UpdateModelMixin,
    CreateModelMixin,
    DeleteModelMixin,
)

from ..serializers import UserShort


class UserConsumer(
    ListModelMixin,
    RetrieveModelMixin,
    PatchModelMixin,
    UpdateModelMixin,
    CreateModelMixin,
    DeleteModelMixin,
    GenericAsyncAPIConsumer,
):
    queryset = User.objects.all()
    serializer_class = UserShort

class MyConsumer(AsyncAPIConsumer):
    @action()
    async def an_async_action(self, some=None, **kwargs):
        # do something async
        return {'response with': 'some message'}, status.HTTP_RESPONSE_OK
  1. routing in django project urls.py = re_path(r"^wss/$", consumers.UserConsumer.as_asgi()),

Output Log

System check identified no issues (0 silenced).
April 04, 2023 - 05:46:08
Django version 4.1.3, using settings 'core.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Internal Server Error: /wss/
Traceback (most recent call last):
  File "C:\Users\SAV\PycharmProjects\python web dev\Dstate\venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
  File "C:\Users\SAV\PycharmProjects\python web dev\Dstate\venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\SAV\PycharmProjects\python web dev\Dstate\venv\lib\site-packages\asgiref\sync.py", line 218, in __call__
    return call_result.result()
  File "C:\Users\SAV\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py", line 438, in result
    return self.__get_result()
  File "C:\Users\SAV\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py", line 390, in __get_result
    raise self._exception
  File "C:\Users\SAV\PycharmProjects\python web dev\Dstate\venv\lib\site-packages\asgiref\sync.py", line 284, in main_wrap
    result = await self.awaitable(*args, **kwargs)
TypeError: app() missing 2 required positional arguments: 'receive' and 'send'
[04/Apr/2023 05:46:12] "GET /wss/ HTTP/1.1" 500 88695
[04/Apr/2023 05:46:12,746] - Broken pipe from ('127.0.0.1', 64411)
  • OS: [WINDOWS 10]
  • Version [10]

Additional context
Add any other context about the problem here.