You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting this error using the EventsViewSet, I installed with the drf package.
Versions:
django_eventstream==5.3.1
daphne==4.1.2
django==5.1.1
djangorestframework==3.15.2
This is the trace:
AttributeError: 'ASGIRequest' object has no attribute '_request'
[01/Oct/2024 19:19:19,879] ERROR:Internal Server Error: /api/v1/chat/events/test/
Traceback (most recent call last):
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/asgiref/sync.py", line 518, in thread_handler
raise exc_info[1]
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/django/core/handlers/exception.py", line 42, in inner
response = await get_response(request)
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
response = await wrapped_callback(
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/asgiref/sync.py", line 468, in __call__
ret = await asyncio.shield(exec_coro)
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/asgiref/current_thread_executor.py", line 40, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/asgiref/sync.py", line 522, in thread_handler
return func(*args, **kwargs)
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
return view_func(request, *args, **kwargs)
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/rest_framework/viewsets.py", line 124, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/django_eventstream/viewsets.py", line 110, in channel
return self._stream_or_respond([channel], request._request)
File "/Users/tomasdussaillant/.local/share/virtualenvs/aorta-api-tCbWVDVZ/lib/python3.10/site-packages/django_eventstream/viewsets.py", line 118, in _stream_or_respond
request = django_request._request
AttributeError: 'ASGIRequest' object has no attribute '_request'
#views.py
class EventsView(EventsViewSet):
permission_classes = [IsAdminOrIsResearch]
channels = ["test"]
#urls.py
from django.urls import path, include
from django_eventstream import views
from rest_framework.routers import DefaultRouter
from .views import EventsView
router = DefaultRouter()
router.register(r'events', EventsView, basename='events')
urlpatterns = [
path("", include(router.urls)),
]
However if I change line 118 in viewsets.py to: request = django_request._request if hasattr(django_request, "_request") else django_request
it works.
I also noticed that if I don't set ASGI_APPLICATION = "core.asgi.application"
Daphne won't let me run, which i feel should be mentioned in the README.
Regular views are working fine, but using the DRF support is useful because i can leverage permission_classes of drf views and integrates seamlessly with my auth logic.
The text was updated successfully, but these errors were encountered:
I'm getting this error using the EventsViewSet, I installed with the drf package.
Versions:
django_eventstream==5.3.1
daphne==4.1.2
django==5.1.1
djangorestframework==3.15.2
This is the trace:
This my view:
However if I change line 118 in viewsets.py to:
request = django_request._request if hasattr(django_request, "_request") else django_request
it works.
I also noticed that if I don't set
ASGI_APPLICATION = "core.asgi.application"
Daphne won't let me run, which i feel should be mentioned in the README.
Regular views are working fine, but using the DRF support is useful because i can leverage permission_classes of drf views and integrates seamlessly with my auth logic.
The text was updated successfully, but these errors were encountered: